4
0

container_socket.adoc 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. == Setup if running inside a container
  2. You can control other containers, when running OliveTin inside a container
  3. itself, however you need to do some extra setup when creating the OliveTin
  4. container.
  5. === Ensure your container has permissions to control docker
  6. You have two alternatives to allow OliveTin (running inside a container) to talk to the Docker daemon through the bind-mounted socket. Pick one:
  7. ==== Option 1 — Use `--privileged` (simplest)
  8. NOTE: Simplest for most users. Podman does not have this requirement.
  9. - Run the container with `--privileged` and as `root` (eg `--user root`).
  10. - This avoids user/group permission issues on `/var/run/docker.sock`.
  11. If you are getting "permission denied" errors it is probably because OliveTin runs as user UID 1000 by default, which is not allowed by your docker host. Running with `--user root` under `--privileged` resolves this quickly. Note that xref:troubleshooting/puid-pgid.adoc[PUID and PGID variables will not work].
  12. ==== Option 2 — Run as non-root in the host `docker` group (no `--privileged`)
  13. Use the standard Docker guidance to manage Docker as a non-root user (becoming a member of the `docker` group) and match the group's GID inside the container so the process can access the socket permissions.
  14. - Docs: https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user[Manage Docker as a non-root user]
  15. - Find the `docker` group GID on the host, for example using `getent group docker`.
  16. - Run the container with your user UID and the `docker` group GID, and bind-mount the socket. Using Compose:
  17. [source,yaml]
  18. .docker-compose.yml
  19. ----
  20. services:
  21. olivetin:
  22. container_name: olivetin
  23. image: jamesread/olivetin
  24. user: ${UID}:${docker_group_id}
  25. volumes:
  26. - /var/run/docker.sock:/var/run/docker.sock
  27. ----
  28. Where `UID` and `docker_group_id` are provided via your shell environment or a `.env` file next to your Compose file, for example:
  29. [source,bash]
  30. .env
  31. ----
  32. UID=1000
  33. docker_group_id=995
  34. ----
  35. This allows you to run the container as a non-root user, while still allowing access to `/var/run/docker.sock`.
  36. === Pass the docker socket into the container
  37. . Pass `/var/run/docker.sock` as a bind mount to the container when creating it, eg:
  38. +
  39. ----
  40. docker create --privileged --user root -v /var/run/docker.sock:/var/run/docker.sock ...additional args here...
  41. ----
  42. +
  43. Or, using the `docker run` syntax;
  44. +
  45. ----
  46. docker run --privileged --user root -v /var/run/docker.sock:/var/run/docker.sock --name OliveTin jamesread/olivetin
  47. ----
  48. +
  49. . The official x86_64 docker container comes with the `docker` client pre-installed. If you are using `arm` or and `arm64` container, you will need to add Docker yourself.
  50. +
  51. xref:reference/containerInstallPackages.adoc[How to install additional packages in the container]
  52. +
  53. NOTE: The reason that the `arm` and `arm64` containers do not include docker, is that when these images are cross-compiled at build time, it takes FOREVER because we have to emulate arm.
  54. After you have passed the socket into the container (and optionally installed docker), you should be able to setup docker actions like it's shown in the example <<example-control-containers,above>>.