4
0

docker_compose.adoc 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. [#install-compose]
  2. = Docker Compose install
  3. Docker compose is a popular way to define multi-container applications using a
  4. infrastructure as code approach.
  5. If you personally prefer to use `docker compose`, then here is a sample to get
  6. you started;
  7. [source,yaml]
  8. .`docker-compose.yml`
  9. ----
  10. services:
  11. olivetin:
  12. container_name: olivetin
  13. image: jamesread/olivetin
  14. volumes:
  15. - OliveTin-config:/config # replace host path or volume as needed
  16. ports:
  17. - "1337:1337"
  18. restart: unless-stopped
  19. volumes:
  20. OliveTin-config:
  21. external: false
  22. ----
  23. include::partial$install/post_container.adoc[]
  24. [#compose-docker-socket]
  25. == Controlling other docker containers from a Docker Compose install of OliveTin
  26. If you want OliveTin running in a container to control other Docker containers, pass the Docker socket into the service and give the container process membership in the same numeric `docker` group that owns the socket on the host.
  27. On many Linux installs, Docker Engine creates a `docker` group automatically; see https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user[Manage Docker as a non-root user] in the Docker documentation.
  28. === Find the `docker` group GID on the host
  29. On the Docker host, read the `docker` group numeric ID (third field of the output):
  30. [source,bash]
  31. ----
  32. getent group docker
  33. ----
  34. If that command prints nothing, create the group or finish Docker post-install steps first, then retry.
  35. === Add the socket mount and `group_add` in Compose
  36. In `docker-compose.yml`, bind-mount the socket and add `group_add` with that GID (as a string is fine). Replace the example GID with the value from your host:
  37. [source,yaml]
  38. .`docker-compose.yml` including Docker socket access without running as root
  39. ----
  40. services:
  41. olivetin:
  42. container_name: olivetin
  43. image: jamesread/olivetin
  44. volumes:
  45. - /docker/OliveTin:/config # replace host path or volume as needed
  46. - /var/run/docker.sock:/var/run/docker.sock
  47. group_add:
  48. - "992" # <1>
  49. ----
  50. <1> Replace `992` with the GID from `getent group docker` on the machine where Compose runs. The number is not portable between hosts.
  51. This keeps the default container user while allowing access to `/var/run/docker.sock`, which is usually tighter than running the whole service as `root`.
  52. See xref:action_examples/containers.adoc[containers] for `docker run`, `--privileged`, and other options if you cannot use a `docker` group on the host.
  53. == Running the OliveTin container as a different user in Compose
  54. If you need the service to run as a specific Unix user in Compose for reasons other than Docker socket access, set `user` explicitly, for example:
  55. [source,yaml]
  56. ----
  57. services:
  58. olivetin:
  59. container_name: olivetin
  60. image: jamesread/olivetin
  61. user: "1000:1000"
  62. ...
  63. ----
  64. For Docker socket access from Compose, prefer <<compose-docker-socket,`group_add` with the host `docker` group GID>> instead of `user: root`.
  65. NOTE: xref:troubleshooting/puid-pgid.adoc[PUID and PGID are not used] by the official OliveTin container image.
  66. [#docker-compose-traefik]
  67. == Using Traefik with Docker Compose
  68. Traefik is a popular reverse proxy that seems to be used a lot in people's
  69. Docker compose setups. See the xref:reverse-proxies/traefik.adoc[Traefik + Docker Compose] page for more details.