Skip to content

Understanding Docker Compose: Equivalence to a Specific docker Command for an Emby Server Setup

Lately, I’ve been exploring docker with my two-week immersion. Recently discovering the power of Docker Compose through documentation from Jellyfin, and successfully deploying a Jellyfin container on Ubuntu Server (22.04.4 LTS). The experience has been quite rewarding!

To broaden my skills, I’m now attempting to set up Emby using Docker Compose as an exercise—a task previously performed with the docker run command:

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’ve translated this to a Docker Compose file with some initial success, but the container won’t stay up—it restarts indefinitely. Here is my first attempt at translating into compose syntax:

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
      
    restart: 'unless-stopped'

However, after running docker-compose up -d, the server restarts again and again. Here’s what I see when checking its status in my console:

![Docker Compose Container Restart Log](<image_placeholder>restarting Emby container)
Note: Replace <image_placeholder> with a relevant image or symbolic representation of the restart log.

Given that docker is brand new to me, I’m not quite sure where my Compose syntax might be off. Here are some potential questions for investigation and clarification on this issue:

  1. Environment Variables vs Docker Directives – When comparing between --env UID=1001 --restart unless-stopped in docker run, to using the compose file, I’m unsure of how they translate—especially with setting up correct user contexts within containers via Compose.
  2. Docker User Permissions – Docker sets a new UID and GID upon container creation; does this mean that environment variables for these don’t apply when using compose, or is there another way to ensure the same permissions in my setup?
  3. Restart Behavior Understanding: When I specify restart:'unless-stopped', what implications should it have on container behavior and why might this be causing restarts if they seem unrelated according to Docker Compose documentation?
    Note: Replace <compose_docs_link> with actual document link.
  4. Volumes Configuration Understanding – My volumes setup should, in theory, match the docker run configuration; is there a specific permission or context setting I’m overlooking here that could affect container startup?
    Note: Replace <compose-volumes_link> with relevant documentation on how compose handles volume configurations.
  5. Docker Compose and Docker Run Differences – What are the key differences between running a single service via docker run vs using .env settings, user contexts from an environment variable standpoint?
    Note: Replace <compose_run-vs-comp>, with information about these practices.
  6. Troubleshooting Compose Setups – Beyond the differences above and common pitfalls when translating docker run syntax to Docker Compose, what are some ways I can troubleshoot this issue?
    Note: List out steps/tools for diagnosing compose file issues.
  7. Docker Best Practices Questions (for future reference) – What general advice should one keep in mind when translating complex docker run configurations into Docker Compose, especially regarding permissions and environment variables that may not have direct equivalents?
    Note: Provide a guide on best practices for ensuring correct context setup using compose.

Next Post
Understanding CI PIPELINE SOURCE merge request eve