patterndockerMinor
What’s the docker compose equivalent of my docker command?
Viewed 0 times
theequivalentwhatdockercomposecommand
Problem
I’ve been using the command line for docker for 2 weeks and just learned how to use
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:
I can’t figure out the difference between the above command line and the following compose file I “translated”:
I use
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?
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:latestI 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 agoI’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?
Solution
Your compose file looks mostly correct, but there's a small difference between the
To make your Docker Compose file equivalent to the original
After making these changes, try running
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.Code Snippets
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'Context
StackExchange DevOps Q#19034, answer score: 1
Revisions (0)
No revisions yet.