Skip to content

An example on how to avoid volume permissions problems with docker (compose) with a user, without root

Notifications You must be signed in to change notification settings

gmolveau/docker-volume-permissions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-volume-permissions

An example on how to avoid volume permissions problems with docker (compose) with a user without root privileges

This example solves this problem with a custom entrypoint, that reads env variables to change the UID and GID of the current user of the docker container to match the desired ones (usually the current user of the host).

Take into consideration that with this solution, the container initially starts as root, but the entrypoint then switches to another user to run your command.

It is possible to use another method using the setuid bit, but it has some caveats (eg. impossible to restart a container because the setuid can only be used once - so only useful for ephemeral containers).

Try it

docker compose build --no-cache
docker compose up
# notice that a `ok.txt` file has been created with the correct permissions in the `data` folder
docker compose down
docker image rm vol:test

Sources and inspirations

About

An example on how to avoid volume permissions problems with docker (compose) with a user, without root

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages