Build rust project containing build script inside a bind mounts of Windows container


Nowadays, it is very common to use a docker container with bind mounts to develop programs, where the bind mounts contain the source code and docker container itself takes charge of environment setup.

For example:

docker run --mount type=bind,source=host/path/to/src,target=guest/path/to/src my-image

Using the command above, we can modify source codes without docker commit each time, and my-image just stores all other environment-related things.


In a Windows container (not just a docker container in Windows, it is a container running Windows inside Windows using hyper-V), if we put rust source code in a bind mounts, and the rust project contains, then cargo build will fail because of "access denied".

There is an issue I found in cargo's GitHub repo: cargo#9193, which contains detailed information about this problem.

Root cause

After searching for similar problems, I thought the root cause for this problem is illustrated in this issue, which says that rustc can't deal with some Windows symlinks, while bind mounts inside Windows container is a symlink which can't be handled properly.

There is a feature request in rust which is also related to this issue.

Microsoft has a web page about permissions inside bind mounts of Windows container, but changing permissions to "Authenticated Users" doesn't work for me.

I am quite frustrated about this problem, since the rust project I worked with is Windows specific (which requires a specific Windows version), so I can't use other OS to develop.

I think this problem is quite general (which is not a crate-specific or version-specific), and if there is a workaround, it may helps a lot for developers who design Windows rust project.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.