File permissions on Linux Docker container running on a Windows host

I have a general question regarding permissions between a windows host and a linux based container.

Assume I have an ubuntu container called BUILD and it is running on a Windows host.

BUILD is supposed to create a bunch of files in /tmp/data.

/tmp/data is however mounted from the host filesystem. The container Dockerfile has this:

VOLUME ["/tmp/data"]

and the container was started like so:

docker run -v C:\tmp\data:/tmp/data -d --name BUILDER BUILDER_IMAGE

I want the files created in C:\tmp\data to only be accessible to a specific windows user and / or group. How can I make sure that the files created by BUILD have the user permissions I want in windows?


  • When you're building your Docker container, adding the line

    USER username

    would change the default user of the docker container (to the user named username).

    However, you should ensure that the user username actually has write permissions to the mounted volume.

    You can then run your Docker run commands with the flag -u username to have the new files created in the mounted directory belong to username.

    docker run -v C:\tmp\data:/tmp/data -d --name -u username BUILDER BUILDER_IMAGE