I'm configuring a docker container for development purposes with the intent to re-configure it (minimally) for k8s cluster deployment. Immediately I run into the issue of user permissions with volume mounts to my local source directory.
For deployment to the cluster I will bake my source directory into the image, which is really the only change I would want to make for deployment.
I've read many SO articles suggesting running as your local user/group id (1000/1000 in my case).
- In docker, writing file to mounted file-system as non-root?
- Docker creates files as root in mounted volume
- Let non-root user write to linux host in Docker
- Understanding user file ownership in docker: how to avoid changing permissions of linked volumes
- Is it possible/sane to develop within a container Docker
But all of those questions seem to glance over a seemingly critical detail. When you use --user
to alter your user ID within the docker container you lose root
, and along with it a lot of functionality, for example whoami
doesn't work. It seems to become very cumbersome to test configuration changes in the docker environment, which is common during development.
The options for developing directly into the docker container seem very limited:
- Add user/group 1000/1000 to the docker image, which seems to violate the run-anywhere mantra of docker/kubernetes.
- chown all your files constantly during development and use root in the container.
Are there other options to this list that is more palatable for developing directly into a docker container?