Original repository at github.
- run container with current host user uid/gid ("worker user")
- how provide home directory when uid/gid of worker user not known at build time
- how to grant access to docker.socket to worker user
- run container and entrypoint as root
- create user/group entry for worker user on startup
- add user to docker group when docker.sock provided
- execute command as worker user
docker build --tag docker-user-adapting-entrypoint:local .
# WORKER_ vars are optional
docker run -ri --rm \
-e WORKER_UID=$(id -u) \
-e WORKER_GID=$(id -g) \
-e WORKER_HOME=/home/sweethome \
-e WORKER_NAME=wrkr \
-v volume-in-work-dir:/work \
docker-user-adapting-entrypoint:local bash
# WORKER_ vars are optional
docker run -ri --rm \
-e WORKER_UID=$(id -u) \
-e WORKER_GID=$(id -g) \
-e WORKER_HOME=/home/sweethome \
-e WORKER_NAME=wrkr \
-v volume-in-work-dir:/work \
-v /var/run/docker.sock:/var/run/docker.sock \
docker-user-adapting-entrypoint:local bash
Written by Cornelius Buschka.