4

I’ve been using the command line for docker for 2 weeks and just learned how to use docker compose yesterday using the excellent documentation I found at Jellyfin. I got a Jellyfin container up and running in a jiffy on my new Ubuntu Server (22.04.4 LTS) and couldn’t be happier.

I thought I’d go back to Emby and learn how to create a compose file as an exercise.

I currently use the following command line to successfully bring up Emby:

docker run -d \
        --name embyserver \
        --volume /home/udance4ever/emby:/config \
        --volume emby-cache:/cache \
        --volume /home/udance4ever/mnt/userdata/kodi:/userdata/kodi \
        --device /dev/dri:/dev/dri \
        --publish 8096:8096 \
        --publish 8920:8920 \
        --env UID=1001 \
        --env GID=1001 \
        --restart unless-stopped \
                emby/embyserver:latest

I can’t figure out the difference between the above command line and the following compose file I “translated”:

version: '3.5'

volumes:
  emby-cache:

services:
  embyserver:
    image: emby/embyserver:latest
    container_name: embyserver
    user: 1001:1001

    ports:
      - "8096:8096"
      - "8920:8920"

    volumes:
      - /home/udance4ever/emby:/config
      - emby-cache:/cache
      - /home/udance4ever/mnt/userdata/kodi:/userdata/kodi

    devices:
      - /dev/dri:/dev/dri

    restart: 'unless-stopped'

I use docker compose up -d to bring up the server and it just keeps restarting:

a0b30f16f381   emby/embyserver:latest   "/init"                About a minute ago   Restarting (1) 3 seconds ago

I’m real new to docker so I don’t know where to begin to debug this compose file (and reverted to recreating the container using the command line which, again, works without error)

I’m posting here because I think it’s less about Emby and more about my understanding of how Docker compose works and its grammar.

Why does my compose file produce different results?

1 Answer 1

2

Your compose file looks mostly correct, but there's a small difference between the user specification. In your original docker run command, you're using environment variables (--env UID=1001 and --env GID=1001) to set the user, while in the docker compose file, you are using the user directive directly.

To make your Docker Compose file equivalent to the original docker run command, you can add the environment section for setting the UID and GID. You can try out the below compose file:

version: '3.5'

volumes:
  emby-cache:

services:
  embyserver:
    image: emby/embyserver:latest
    container_name: embyserver
    
    ports:
      - "8096:8096"
      - "8920:8920"

    volumes:
      - /home/udance4ever/emby:/config
      - emby-cache:/cache
      - /home/udance4ever/mnt/userdata/kodi:/userdata/kodi

    devices:
      - /dev/dri:/dev/dri

    environment:
      - UID=1001
      - GID=1001

    restart: 'unless-stopped'

After making these changes, try running docker-compose up -d again, and it should bring up the Emby server without continuously restarting.

1
  • wow! that is such a subtle difference and sure enough, it worked - thank you :) what documentation may I read to better understand when the user directive is relevant vs user environment variables? I poked around a little bit and only see articles on one or the other. Commented Mar 13 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.