I would like to use Traefik as an rootless image, therefore supplying a user/group in compose. The challenge I have is that I need to supply a volume to persist LetsEncrypt certificates to not run into issuing limits. I expected a new volume to play nice with arbitrary user/group, but that seems not the case.
Example docker-compose.yml
for docker compose
and docker stack deploy
:
version: '3.9'
services:
debian:
image: debian:stable-slim
hostname: '{{.Node.Hostname}}'
user: 1001:1002
deploy:
mode: global
volumes:
- debian-volume:/volume
entrypoint: ["/bin/sh", "-c"]
command:
- |
echo Starting Debian
cd /volume
touch hello.world
sleep 1000000
volumes:
debian-volume:
name: debian-volume
As the volume is brand new and empty, I would expect that the container can simply create a file inside, but instead I see touch: cannot touch 'hello.world': Permission denied
.
So how can I use a container with uid/giu unknown on host to write to an attached Docker volume? Or is this not possible and the uid/gid always need to exist on host to write to a Docker Volume?