Answers: <p>Your compose file looks mostly correct, but there's a small difference between the <code>user</code> specification. In your original <code>docker run</code> command, you're using environment variables (--env UID=1001 and --env GID=1001) to set the <code>user</code>, while in the docker compose file, you are using the <code>user</code> directive directly.</p>
  <p>To make your Docker Compose file equivalent to the original <code>docker run</code> command, you can add the environment section for setting the <strong>UID</strong> and <strong>GID</strong>. You can try out the below compose file:</p>
  <pre><code>version: '3.5'
  
  volumes:
    emby-cache:
  
  services:
    embyserver:
      image: emby/embyserver:latest
      container_name: embyserver
      
      ports:
        - &quot;8096:8096&quot;
        - &quot;8920:8920&quot;
  
      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'
  </code></pre>
  <p>After making these changes, try running <code>docker-compose up -d</code> again, and it should bring up the Emby server without continuously restarting.</p>
  
Answers: CC BY-SA 4.0
Answers: 2024-03-13T19:24:13.257Z
Answers: 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.
Answers: udance4ever
Answers: CC BY-SA 4.0
Answers: 2024-03-13T12:25:29.347Z
Answers: 2024-03-13T12:25:29.347Z
Answers: Ajay
Body: <p>I’ve been using the command line for docker for 2 weeks and just learned how to use <code>docker compose</code> yesterday using the excellent <a href="https://jellyfin.org/docs/general/installation/container/" rel="nofollow noreferrer">documentation I found at Jellyfin</a>. 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.</p>
  <p>I thought I’d go back to Emby and learn how to create a compose file as an exercise.</p>
  <p>I currently use the following command line to successfully bring up Emby:</p>
  <pre><code>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
  </code></pre>
  <p>I can’t figure out the difference between the above command line and the following compose file I “translated”:</p>
  <pre><code>version: '3.5'
  
  volumes:
    emby-cache:
  
  services:
    embyserver:
      image: emby/embyserver:latest
      container_name: embyserver
      user: 1001:1001
  
      ports:
        - &quot;8096:8096&quot;
        - &quot;8920:8920&quot;
  
      volumes:
        - /home/udance4ever/emby:/config
        - emby-cache:/cache
        - /home/udance4ever/mnt/userdata/kodi:/userdata/kodi
  
      devices:
        - /dev/dri:/dev/dri
  
      restart: 'unless-stopped'
  </code></pre>
  <p>I use <code>docker compose up -d</code> to bring up the server and it just keeps restarting:</p>
  <pre><code>a0b30f16f381   emby/embyserver:latest   &quot;/init&quot;                About a minute ago   Restarting (1) 3 seconds ago
  </code></pre>
  <p>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)</p>
  <p>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.</p>
  <p>Why does my compose file produce different results?</p>
  
Tags: <docker><docker-compose><ubuntu>
Title: What’s the docker compose equivalent of my docker command?
UserDisplayName: udance4ever
ThreadText: # What’s the docker compose equivalent of my docker command?
  
  (Asked by: username_0 on 2024-03-12)
  
  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](https://jellyfin.org/docs/general/installation/container/). 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/username_0/emby:/config \
          --volume emby-cache:/cache \
          --volume /home/username_0/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/username_0/emby:/config
        - emby-cache:/cache
        - /home/username_0/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?
  
  **Tags:** docker, docker-compose, ubuntu
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-03-13. Score: 3 | Accepted answer
  
  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/username_0/emby:/config
        - emby-cache:/cache
        - /home/username_0/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.
  
  > **Comments:**
  > **username_0**: 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.  
  
  ---
  
  