I’m running Windows 11, Docker Desktop + WSL2 Ubuntu (WSL2 engine enabled) - Docker Desktop 4.29.0 (145265), server version 26.0.0.
Here’s the output of my docker context ls. This displays the same for both Windows cmd and wsl2 terminal:
default * moby Current DOCKER_HOST based configuration unix:///var/run/docker.sock
desktop-linux moby Docker Desktop npipe:////./pipe/dockerDesktopLinuxEngine
Docker info command shows both with a server version 26.0.0, and a root dir of /var/lib/docker
In my docker-compose file I have a bind mount: __pypackages__:/app/__pypackages__
The issue is that on my host, in Ubuntu, where my project is located, this folder is created after I do a docker compose up --build
with root:root
ownership. This is causing file permission errors, because it is set as python:python
in the container (and in my Dockerfile). Example: [PermissionError]: [Errno 13] Permission denied: '/app/__pypackages__/3.12'
My Dockerfile explicitly sets the UID and GID to 1000, and my USER to python.
So the question is, how can I fix it so that when I run my build, docker creates the host bind mount folder with the UID and GID as 1000 like it is in the container, instead of root:root, so that I don’t get perm errors anymore?
I realize I could just make the bind mount folder manually with the UID and GID set to 1000 before I initialize my containers, instead of having Docker create it for me on the host, but I’d much rather avoid having to do that for every bind mount I create, and that would also mean I need to commit empty folders to my git repo with the perms set.