Tzahi12345 / YoutubeDL-Material

Self-hosted YouTube downloader built on Material Design
MIT License
2.56k stars 266 forks source link

Gluetun Docker Support #1085

Open truthsword opened 6 months ago

truthsword commented 6 months ago

I've tried to run this through my Gluetun docker container, and I cannot bring up the interface. Seems related to Mongo, but I'm unsure how to work around this. Anyone?

jshatch commented 1 month ago

Here's how I got this working. I'm using compose.

You need to have both the ytdl_material and ytdl-mongo-db containers using the gluetun network:

    network_mode: "service:gluetun"

Then you need to set your ytdl-mongodb url to localhost:27017:

    environment:
      ytdl_mongodb_connection_string: 'mongodb://localhost:27017'

Here are my full config blocks.

  ytdl_material:
    environment:
      ytdl_mongodb_connection_string: 'mongodb://localhost:27017'
      ytdl_use_local_db: 'false'
      write_ytdl_config: 'true'
    restart: always
    network_mode: "service:gluetun"
    depends_on:
      - ytdl-mongo-db
    volumes:
      - ./appdata:/app/appdata
      - ./audio:/app/audio
      - ./ytvideo:/app/video
      - ./subscriptions:/app/subscriptions
      - ./users:/app/users
    image: tzahi12345/youtubedl-material:latest

  ytdl-mongo-db:
    # If you are using a Raspberry Pi, use mongo:4.4.18
    image: mongo:4
    logging:
        driver: "none"
    container_name: mongo-db
    restart: always
    network_mode: "service:gluetun"
    volumes:
      - ./db:/data/db
truthsword commented 1 month ago

Thank you for your post. In the meantime I seem to have sorted this out in a similar way

services:
  ytdl_material:
    image: tzahi12345/youtubedl-material:nightly
    restart: always
    depends_on:
      - ytdl-mongo-db
    container_name: ytdl-material
    environment:
      ytdl_mongodb_connection_string: mongodb://ytdl-mongo-db:27017
      ytdl_use_local_db: "true"
      write_ytdl_config: "true"
    volumes:
      - appdata:/app/appdata
      - /mnt/zxcv/downloads/audio:/app/audio
      - /mnt/zxcv/downloads/video:/app/video
      - subscriptions:/app/subscriptions
      - users:/app/users
    network_mode: "container:gluetun"

  ytdl-mongo-db:
    image: mongo:4
    restart: always
    container_name: mongo-db
    logging:
      driver: none
    volumes:
      - db:/data/db
#   network_mode: "container:gluetun"

volumes:
  appdata:
  subscriptions:
  users:
  db:

What is different here is that the mongo container is not tied to gluetun. I'm not sure if this is correct, but it appears to work without logging errors.

jshatch commented 1 month ago

When I tried that I had no network connectivity to the mongo container. Actually it looks like you might not even be using mongo, you have ytdl_use_local_db: "true" set, that's actually what I ended up doing because my instance would end up going braindead after about 6 hours and I think it's because mongo was having trouble. So I'm not even running that container anymore.

jshatch commented 1 month ago

Also after some more thinking about this, I realized that I don't need to forward the mongo port in the gluetun container since in my original example they're sharing the network and I'm not hitting it from external. (I edited my previous comment to reflect that)

truthsword commented 1 month ago

Following your compose I seemingly have mongo now connected. "localhost" was the key. In the process I've “lost” my local database information, but as it was just beginning, I'm not too far out of pocket.

One difference… using network_mode: "service:gluetun" didn't work for me, even though “gluetun” is the service name. Maybe that's because gluetun lives in a separate compose file for me. Using network_mode: "container:gluetun" however works, and I verified the IP and connectivity to ensure the YT container was properly connected.