midarrlabs / midarr-server

πŸ”₯Midarr, the minimal lightweight media server.
MIT License
1.23k stars 39 forks source link

Experiencing issues with docker compose #403

Closed dannydanchev closed 1 year ago

dannydanchev commented 1 year ago

Hey I am in the process of setting up my very first home media server on an old Athlon X2 machine. I've successfuly managed to get the *arr stack running with hardlinks set up as per the TRaSH guides and needed a simple and lightweight way to stream my media files. So far midarr-server seems to be exactly what I am looking for but I am facing some issues regarding the docker compose setup.

I keep my docker-compose.yml files each in a seperate directory under /srv/<service-name> and then each container data resides in /srv/<service-name>/appdata. To "connect" them together I have created a docker network called docker-network.

Following the docker compose example in the README I created a new database-data volume but after running docker compose up I got the following error: All dependencies are up to date psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory Crash dump is being written to: erl_crash.dump... midarr exited with code 1

I also tried keeping the database under /srv/midarr/data but got the same error. My docker-compose.yml is attached bellow:

version: "3.7"

services:
  midarr:
    container_name: midarr
    image: ghcr.io/midarrlabs/midarr-server:latest
    ports:
      - 4000:4000
    volumes:
      - /home/danny/storage/media/library:/media/library
    environment:
#       App config
      - APP_URL=http://midarr:4000
      - APP_MAILER_FROM=example@email.com
      - SENDGRID_API_KEY=someApiKey

#       Database config
      - DB_USERNAME=my_user
      - DB_PASSWORD=my_password
      - DB_DATABASE=my_database
      - DB_HOSTNAME=postgresql

#       Admin account
      - SETUP_ADMIN_EMAIL=admin@email.com
      - SETUP_ADMIN_NAME=admin
      - SETUP_ADMIN_PASSWORD=passwordpassword # minimum length 12

#       Radarr integration
      - RADARR_BASE_URL=radarr:7878
      - RADARR_API_KEY=hidden

#       Sonarr integration
      - SONARR_BASE_URL=sonarr:8989
      - SONARR_API_KEY=hidden

#       OIDC / OAuth 2.0 integration
#      - OAUTH_CLIENT_ID=someClientId
#      - OAUTH_CLIENT_SECRET=someClientSecret
#      - OAUTH_ISSUER_URL=http://some-provider.url
#      - OAUTH_AUTHORIZE_URL=http://some-provider.url/authorize
#      - OAUTH_TOKEN_URL=http://some-provider.url/token
#      - OAUTH_REDIRECT_URI=http://some-provider.url/auth/callback
#      - OAUTH_USER_URL=http://some-provider.url/user
    networks:
      - docker-network
    depends_on:
      postgresql:
        condition: service_healthy

  postgresql:
    container_name: postgresql
    image: postgres
    volumes:
      - /srv/midarr/data:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=my_user
      - POSTGRES_PASSWORD=my_password
      - POSTGRES_DB=my_database
    networks:
      - docker-network
    healthcheck:
      test: "exit 0"

networks:
  docker-network:
    external: true

Only time I managed to get a different output was when following the docker-compose.yml file in the master branch and I added a /app directory for midarr in but then got this output Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/app/entry.sh": stat /app/entry.sh: no such file or directory: unknown

I am quite new to managing containers with docker compose and would really appreciate some feedback on what I might be doing wrong.

Running Debian 12 with Docker version 24.0.5.

My Radarr docker-compose.yml file

version: "3.7"

services:
  radarr:
    container_name: radarr
    image: ghcr.io/hotio/radarr
    ports:
      - "7878:7878"
    environment:
      - PUID=1000
      - PGID=1000
      - UMASK=002
      - TZ=Europe/Sofia
    volumes:
      - /srv/radarr/appdata:/config
      - /home/danny/storage/media:/media
    networks:
      - docker-network

networks:
  docker-network:
    external: true
trueChazza commented 1 year ago

Hi sorry to hear you've had some issues.

Only time I managed to get a different output was when following the docker-compose.yml file in the master branch and I added a /app directory for midarr in but then got this output Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/app/entry.sh": stat /app/entry.sh: no such file or directory: unknown

^This is similar to the error logged by my Raspberry Pi before we added arm64 support. Our release build supports architectures amd64 and arm64 which I would have thought your machine falls under amd64

Could you try running Midarr on a more recent machine and see if that works?

I ran a fresh README docker compose on an Intel i7 ubuntu server without any issue.

trueChazza commented 1 year ago

Oh never mind, I misread the errors. It looks like Midarr does successfully build, but crashes when looking for the entry point script.

dannydanchev commented 1 year ago

I tried forking the repo and running the docker-compose.yml and that one does start successfuly. I believe I might be experiencing some sort of permission issue? For example recyclarr in the same /srv/recyclarr/... directory starts, but when I try to create a config file it fails to do so. I had to run sudo chown -R 1000:1000 /srv/recyclarr/appdata and that fixed the issue. However trying the same with midarr doesn't seem to help. I am using hotio's docker images and he seems to have PUID and PGID under the environment tab in his compose files. Trying to add them in midarr doesn't help thoe.

trueChazza commented 1 year ago

I was able to replicate the issue. Midarr will crash if either your Radarr or Sonarr is unreachable. Please make sure their config are both set and correct.

trueChazza commented 1 year ago

Can you give this a try? Just put in your Radarr and Sonarr details:

version: "3.4"

volumes:
  postgresql-data:

services:

  midarr:
    container_name: midarr
    image: ghcr.io/midarrlabs/midarr-server:latest
    ports:
      - 4000:4000
    environment:
      - APP_URL=http://midarr:4000

      - DB_USERNAME=my_user
      - DB_PASSWORD=my_password
      - DB_DATABASE=my_database
      - DB_HOSTNAME=postgresql

      - SETUP_ADMIN_EMAIL=admin@email.com
      - SETUP_ADMIN_NAME=admin
      - SETUP_ADMIN_PASSWORD=somepassword

      - RADARR_BASE_URL=radarr:7878 # required
      - RADARR_API_KEY=someApiKey # required

      - SONARR_BASE_URL=sonarr:8989 # required
      - SONARR_API_KEY=someApiKey # required

    depends_on:
      postgresql:
        condition: service_healthy

  postgresql:
    container_name: postgresql
    image: postgres
    volumes:
      - postgresql-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=my_user
      - POSTGRES_PASSWORD=my_password
      - POSTGRES_DB=my_database
    healthcheck:
      test: "exit 0"
dannydanchev commented 1 year ago

Success!! Using the provied docker-compose.yml I was able to start the container and launch the web interface. Only had to add my media library and I am watching. Would it be possible to have the postgresql-data volume follow my current mappings and be stored in /srv/midarr/data? And how would I integrate my docker-network in the compose file?

dannydanchev commented 1 year ago

Would it be possible to have the postgresql-data volume follow my current mappings and be stored in /srv/midarr/data? And how would I integrate my docker-network in the compose file?

I was able to achieve this by using the following docker-compose.yml edited to better fit the others I have.
version: "3.7"

services:
  midarr:
    container_name: midarr
    image: ghcr.io/midarrlabs/midarr-server:latest
    ports:
      - "4000:4000"
    environment:
      - APP_URL=http://midarr:4000

      - DB_USERNAME=my_user
      - DB_PASSWORD=my_password
      - DB_DATABASE=my_database
      - DB_HOSTNAME=postgresql

      - SETUP_ADMIN_EMAIL=admin@email.com
      - SETUP_ADMIN_NAME=admin
      - SETUP_ADMIN_PASSWORD=somepassword

      - RADARR_BASE_URL=radarr:7878
      - RADARR_API_KEY=d90f102c62b44fd8adf37f5a9870f123

      - SONARR_BASE_URL=sonarr:8989
      - SONARR_API_KEY=270f828df52441e8b209a7a1118c0123
    volumes:
      - /home/danny/storage/media/library:/media/library
    networks:
      - docker-network
    depends_on:
      postgresql:
        condition: service_healthy

  postgresql:
    container_name: postgresql
    image: postgres
    environment:
      - POSTGRES_USER=my_user
      - POSTGRES_PASSWORD=my_password
      - POSTGRES_DB=my_database
    volumes:
      - /srv/midarr/appdata:/var/lib/postgresql/data
    networks:
      - docker-network
    healthcheck:
      test: "exit 0"

networks:
  docker-network:
    external: true

After running docker system prune -a and then recreating the container from scratch everything works as expected :) (love the UI so far <3)

After taking a more in depth look at the error logs I was experiencing previously and then taking into account the compose file you provided (mentioning that both radarr and sonarr data is required) I can confidently say that this was user error on my part. I only included the radarr API key and deleted the parts mentioning sonarr.

Here are the full logs from back when I was experiencing the issue: ``` [+] Running 2/1 βœ” Container postgresql Created 0.1s βœ” Container midarr Created 0.0s Attaching to midarr, postgresql postgresql | postgresql | PostgreSQL Database directory appears to contain a database; Skipping initialization postgresql | postgresql | postgresql | 2023-09-01 12:33:08.012 UTC [1] LOG: starting PostgreSQL 15.4 (Debian 15.4-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit postgresql | 2023-09-01 12:33:08.012 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 postgresql | 2023-09-01 12:33:08.013 UTC [1] LOG: listening on IPv6 address "::", port 5432 postgresql | 2023-09-01 12:33:08.015 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgresql | 2023-09-01 12:33:08.020 UTC [28] LOG: database system was shut down at 2023-09-01 10:42:08 UTC postgresql | 2023-09-01 12:33:08.028 UTC [1] LOG: database system is ready to accept connections midarr | Resolving Hex dependencies... midarr | Resolution completed in 0.467s midarr | Unchanged: midarr | bcrypt_elixir 3.0.1 midarr | castore 1.0.3 midarr | certifi 2.9.0 midarr | comeonin 5.3.3 midarr | cors_plug 3.0.3 midarr | cowboy 2.10.0 midarr | cowboy_telemetry 0.4.0 midarr | cowlib 2.12.1 midarr | db_connection 2.5.0 midarr | decimal 2.1.1 midarr | ecto 3.10.1 midarr | ecto_sql 3.10.1 midarr | elixir_make 0.7.6 midarr | esbuild 0.7.1 midarr | excoveralls 0.17.0 midarr | exile 0.1.0 midarr | expo 0.4.1 midarr | exstream 0.20.0 midarr | extaima 0.3.0 midarr | extitles 0.1.0 midarr | file_system 0.2.10 midarr | floki 0.34.3 midarr | gettext 0.23.0 midarr | hackney 1.18.1 midarr | httpoison 2.1.0 midarr | idna 6.1.1 midarr | jason 1.4.1 midarr | metrics 1.0.1 midarr | mime 2.0.5 midarr | mimerl 1.2.0 midarr | oauth2 2.1.0 midarr | parse_trans 3.3.1 midarr | phoenix 1.7.7 midarr | phoenix_ecto 4.4.2 midarr | phoenix_html 3.3.2 midarr | phoenix_live_dashboard 0.7.2 midarr | phoenix_live_reload 1.4.1 midarr | phoenix_live_view 0.18.18 midarr | phoenix_pubsub 2.1.3 midarr | phoenix_template 1.0.2 midarr | phoenix_view 2.0.2 midarr | plug 1.14.2 midarr | plug_cowboy 2.6.1 midarr | plug_crypto 1.2.5 midarr | postgrex 0.17.2 midarr | ranch 1.8.0 midarr | scrivener 2.7.2 midarr | ssl_verify_fun 1.1.7 midarr | swoosh 1.11.5 midarr | tailwind 0.2.1 midarr | telemetry 1.2.1 midarr | telemetry_metrics 0.6.1 midarr | telemetry_poller 1.0.0 midarr | tesla 1.7.0 midarr | unicode_util_compat 0.7.0 midarr | websock 0.5.2 midarr | websock_adapter 0.5.3 midarr | All dependencies are up to date midarr | psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory midarr | Is the server running locally and accepting connections on that socket? midarr | midarr | 12:33:42.564 [info] Migrations already up midarr | midarr | 12:33:44.105 [notice] Application media_server exited: MediaServer.Application.start(:normal, []) returned an error: shutdown: failed to start child: MediaServer.SeriesIndex midarr | ** (EXIT) an exception was raised: midarr | ** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): DBConnection.PrepareStream, DBConnection.Stream, Date.Range, Ecto.Adapters.SQL.Stream, Exile.Stream, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Jason.OrderedObject, List, Map, MapSet, Phoenix.LiveView.LiveStream, Postgrex.Stream, Range, Scrivener.Page, Stream midarr | (elixir 1.14.3) lib/enum.ex:1: Enumerable.impl_for!/1 midarr | (elixir 1.14.3) lib/enum.ex:166: Enumerable.reduce/3 midarr | (elixir 1.14.3) lib/enum.ex:4307: Enum.filter/2 midarr | (media_server 4.0.0) lib/media_server_web/repositories/series.ex:17: MediaServerWeb.Repositories.Series.get_all/0 midarr | (elixir 1.14.3) lib/agent/server.ex:8: Agent.Server.init/1 midarr | (stdlib 3.17.2.2) gen_server.erl:423: :gen_server.init_it/2 midarr | (stdlib 3.17.2.2) gen_server.erl:390: :gen_server.init_it/6 midarr | (stdlib 3.17.2.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3 midarr | {"Kernel pid terminate midarr | d",application_controller,"{application_start_failure,media_server,{{shutdown,{failed_to_start_child,'Elixir.MediaServer.SeriesIndex',{#{'__exception__' => true,'__struct__' => 'Elixir.Protocol.Undef midarr | inedError',description => <<>>,protocol => 'Elixir.Enumerable',value => nil},[{'Elixir.Enum midarr | erable','impl_for!',1,[{file,\"lib/enum.ex\"},{line,1}]},{'Elixir.Enumerable',reduce,3,[{file,\"lib/enum.ex\"},{line,166}]},{'Elixir.Enum',filter,2,[{file,\"lib/enum.ex\"},{line,4307}]},{'Elix midarr | ir.MediaServerWeb.Repos midarr | itories.Series',get_all,0,[{file,\"lib/media_server_web/rep midarr | ositories/series.ex\"},{line,17}]},{'Elixir.Agent.Server',init,1,[{file,\"lib/ag midarr | ent/server.ex\"},{line,8}]},{gen_server,init_it,2,[{file,\ midarr | " midarr | gen_server.erl\"},{line,423}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}}},{'Elixir.MediaServer.Application',start,[normal,[]]}}}"} midarr | K midarr | ernel pid terminated (application_controller) ({applic midarr | ation_start_failure,media_server,{{shutdown,{failed_t midarr | o_start_child,'Elixir.MediaServer.SeriesIndex',{#{'__exception__' => true,'__stru midarr | ct__' => 'Elixir.Protocol.UndefinedErro midarr | r',description => <<>>,protocol => 'Elixir.Enumerable',value => n midarr | il},[{'Elixir.Enumerable','impl_for!',1, midarr | [{file,"lib/enum.ex"},{line,1}]},{'Elixir.Enumerable',re midarr | duce,3,[{file,"lib/enum.ex"},{line,166}]},{'Elixir.Enum midarr | ',filter,2,[{file,"lib/enum.ex"},{line,4307}]},{'Eli midarr | xir.MediaServerWeb.Repositories.Series', midarr | get_all,0,[{file,"lib/media_server_web/repositories/ser midarr | ies.ex"},{line,17}]},{'Elixir.Agent.Server',init,1, midarr | [{file,"lib/agent/server.ex"},{line,8}]},{gen_server,ini midarr | t_it,2,[{file,"gen_server.erl"},{line,423}]},{gen_ midarr | server,init_it,6,[{file,"gen_server.erl"},{line,390}]},{proc_lib,in midarr | it_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}}},{'Elixir midarr | .MediaServer.Appl midarr | ication',start,[normal,[]]}}}) midarr | midarr | Crash dump is being writte midarr | n to: erl_crash.dump... midarr | done midarr | Database my_database ready midarr | 12:33:47.251 [info] Running MediaServerWeb.Endpoint with cowboy 2.10.0 at :::4000 (http) midarr | 12:33:47.273 [info] Access MediaServerWeb.Endpoint at http://localhost:4000 midarr | 12:33:47.371 [notice] Application media_server exited: MediaServer.Application.start(:normal, []) returned an error: shutdown: failed to start child: MediaServer.SeriesIndex midarr | ** (EXIT) an exception was raised: midarr | ** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): DBConnection.PrepareStream, DBConnection.Stream, Date.Range, Ecto.Adapters.SQL.Stream, Exile.Stream, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Jason.OrderedObject, List, Map, MapSet, Phoenix.LiveView.LiveStream, Postgrex.Stream, Range, Scrivener.Page, Stream midarr | (elixir 1.14.3) lib/enum.ex:1: Enumerable.impl_for!/1 midarr | (elixir 1.14.3) lib/enum.ex:166: Enumerable.reduce/3 midarr | (elixir 1.14.3) lib/enum.ex:4307: Enum.filter/2 midarr | (media_server 4.0.0) lib/media_server_web/repositories/series.ex:17: MediaServerWeb.Repositories.Series.get_all/0 midarr | (elixir 1.14.3) lib/agent/server.ex:8: Agent.Server.init/1 midarr | (stdlib 3.17.2.2) gen_server.erl:423: :gen_server.init_it/2 midarr | (stdlib 3.17.2.2) gen_server.erl:390: :gen_server.init_it/6 midarr | (stdlib 3.17.2.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3 midarr | { midarr | "Kernel pid termi midarr | nated",ap midarr | p midarr | l midarr | i midarr | c midarr | a midarr | tion_con midarr | t midarr | roller," midarr | { midarr | applica midarr | t midarr | ion_star midarr | t midarr | _failur midarr | e midarr | ,media_ midarr | server,{{ midarr | s midarr | hutdown, midarr | { midarr | failed_to midarr | _ midarr | start_c midarr | h midarr | ild,'Elix midarr | i midarr | r.MediaSe midarr | r midarr | ver.Seri midarr | e midarr | sIndex', midarr | { midarr | #{'__e midarr | x midarr | c midarr | eption__ midarr | ' midarr | => true, midarr | ' midarr | __struc midarr | t midarr | __' => 'E midarr | l midarr | ixir.Pro midarr | t midarr | o midarr | c midarr | o midarr | l.Undef midarr | i midarr | n midarr | e midarr | dError' midarr | , midarr | d midarr | e midarr | script midarr | i midarr | o midarr | n midarr | => <<> midarr | > midarr | , midarr | p midarr | rotoco midarr | l midarr | midarr | = midarr | > midarr | 'Elixir.Enumerable',value => nil},[{'Elixir.Enumerable','impl_for!',1,[{f midarr | il midarr | e,\"lib/enum.ex\"},{line,1}]},{'Elixir.Enumerable',reduce,3,[{fil midarr | e midarr | , midarr | \"lib/enum.ex\"},{line,166}]},{'Elixir.Enum',filter,2,[{file,\"lib/enum.ex\"},{line, midarr | 43 midarr | 07}]},{'Elixir.MediaServerWeb.Repositories.Series',get_all,0,[{file,\"lib/ midarr | med midarr | ia_server_web/repositories/series.ex\"},{line,17}]},{'El midarr | i midarr | xir.Agent.Server',init,1,[{file,\"lib/agent/server.ex\"},{line,8 midarr | } midarr | ] midarr | },{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,4 midarr | 2 midarr | 3}]},{gen_server,init_it,6,[{file,\"gen_server. midarr | er midarr | l\"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,\"pro midarr | c midarr | _lib.erl\"},{line,226}]}]}}},{'Elixir.MediaServer.Applicat midarr | i midarr | o midarr | n',start,[normal,[]]}}}"} midarr | Kernel pid terminated midarr | (ap midarr | plication_controller) ({application_start_failure,media_server,{{shutdown,{failed_to_start_child,'Elixir. midarr | MediaServer.SeriesIndex', midarr | {#{'__exception__' => true,'__struct__' => 'Elixir.Protocol.UndefinedError',description midarr | => <<>>,protocol => 'Elixir.Enumerabl midarr | e',value => nil},[{'Elixir.Enumerable','impl_for!',1,[{file,"lib/enum.ex"},{l midarr | ine,1}]},{'Elixir.Enumerable',reduce,3,[{file,"lib/enum.ex"},{line midarr | , midarr | 166} midarr | ]},{'Elixir.Enum',filter,2,[{file,"lib/enum.ex"},{line,4307}]},{'Elixir.MediaServerWeb.Repositories.Seri midarr | es',get_all,0,[{file,"li midarr | b/media_server_web/repositories/series.ex"},{line,17}]},{'Elixir.Agent.Server',ini midarr | t,1,[{f midarr | ile,"lib/agent/server.ex"},{line,8}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,423}] midarr | } midarr | ,{ midarr | gen_server,init_it,6,[{file,"gen_server.erl"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,"proc_li midarr | b.erl"},{line, midarr | 226}]}]}}},{'Elixir.MediaServer.Application',start,[normal,[]]}}}) midarr | midarr | Cr midarr | ash midarr | dump midarr | is bein midarr | g written to: midarr | erl_cra midarr | sh.dump. midarr | .. midarr | done midarr | midarr exited with code 1 ```

Thank you for helping me resolve an issue caused by me not properly reading and configuring a simple docker compose file facepalm

trueChazza commented 1 year ago

Ah good to hear you were able to resolve this. Thank you for posting detailed info and for your feedback.

trueChazza commented 1 year ago

https://github.com/orgs/midarrlabs/projects/1/views/1?filterQuery=fail

I think this could have been easier to resolve if the error logs were more detailed as to what was failing, so I've added a couple tickets to account. Hopefully be in the next release πŸ˜„

trueChazza commented 1 year ago

Please feel free to reach out anytime with issues or feature ideas! I'm more than happy to help πŸ„β€β™‚οΈ