I am using docker desktop on ubuntu to start and run containers with docker compose.
There is a user id mismatch between host and container which is causing permission issues.
My application is based on this example (the dockerfile is the same) - https://github.com/nickjj/docker-rails-example/blob/main/Dockerfile
At build time it creates a 'ruby' user with uid:gid of 1000:1000. This matches my host id:gid. This worked nicely on my old laptop, but on my new one it seems files owned by the host user appear as owned by root in the container.
When I try chown as the ruby user the files appear as being owned by someone else:
-rw-rw-r-- 1 100999 100999 8318 Nov 22 20:26 README.md
Somewhere the mapping between host and container is not being made. From what I've gathered there are user name space remapping features but these aren't available when using docker desktop. What options are available?
At the moment, I do not have all the details, I just started to use Docker Desktop for Linux recently. But I found a ticket at https://github.com/docker/desktop-linux/issues/31 that explains the situation in detail. Most of the information I add here comes from the discussion in that link, especially from the answers by p1-0tr
. In summary:
<username>:<startingUid>:65536
(second answer to your question), and startingUid would be something like 1000. But if your user is already 1000, the root user at the container will be 1000, and then you will have problems. I suggest using a range that does not contain your user (which also means that it will not map to your user, but something else). I did not investigate this further, so if someone has something to add here, please do it. However, this solution is not recommended because it will raise privileges for Docker Desktop and thus should be avoided.sudo addgroup --gid 100999 <group name>
) on your host machine, add your user to this group, and give the group permission to the files. The files will be accessible from both places (third answer to your question, but not exactly as you expect). Please check that ticket on GitHub above for more details./home/<youruser>/.docker/config.json
after uninstalling/disabling Docker Desktop for Linux. I do not remember the error message I had and do not have the environment to replicate it to add details, but if you have issues with Docker later, this is a starting point for you to look into.