Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File creation within a Docker bind mount doesn't appear in WSL until lxss is restarted. #3571

Closed
stshrive opened this issue Sep 26, 2018 · 3 comments

Comments

@stshrive
Copy link

Microsoft Windows [Version 10.0.17134.285]

Using docker bind mounts to modify files on host system

Repro:
Set an environment variable in Windows that points to the Windows package for WSL:
DOCKER_MOUNT_LOCATION
image

Make this variable available in WSL:
image

have docker for windows installed.
Setup WSL to run docker on Windows

in WSL console, run:

docker pull ubuntu
docker run -it --mount type=bind,source="$DOCKER_MOUNT_LOCATION/home/<wsl_username>",target=/mnt/mounted ubuntu bash

inside container:

cd /mnt/mounted
touch any_new_file.anything

In a separate WSL Window:

cd ~/
ls -la

any_new_file.anything does not appear.

Try touching this file in the second WSL window.

touch any_new_file.anything

image

In CMD window

cd %DOCKER_MOUNT_LOCATION%\home\<wsl_username>
dir

image

Exit all WSL windows and open a new WSL console window:
image

NOTE: The lack of permissions may be due to this same issue or may be strictly to Docker, however, this permissions issue appears regardless of setting the dockerfile user to the same UID and GID as the WSL user
i.e. uid=(1000) gid=(1000)

Ideally, when running a docker container with a bind mount to a host windows directory, changes that occur in the docker container appear in the WSL console. (They do appear in CMD console).

You should not get file Input/Output error when trying to access the files.

@DHowett-MSFT
Copy link

DHowett-MSFT commented Sep 26, 2018

This is no different than using any other Windows application to modify files inside the WSL rootfs, which you're not supposed to do. Involving Docker doesn't change anything -- you're just adding more complicated steps to achieve the same goal. Ref #45, #87, #154, #552, #659.

@stshrive
Copy link
Author

I would like to point out that the files I am referencing are mounted in the directory that the link you have provided points out. WSLENV translates this file path to a path on the /c/<dir> when executed (I have my default mount point setup to be /c, not /mnt.

Another thing the link points out is not modifying files here: %localappdata%\lxss, which I am not using, or accessing in any way. However, I think the main point is the OS metadata being different for Linux and Windows. Which, of course, makes sense.

Are you essentially telling me it is impossible to run docker from WSL (or that this is in fact a bug on docker)?

@DHowett-MSFT
Copy link

DHowett-MSFT commented Sep 27, 2018

Sorry about that. The directory AppData\Local\Packages\<package>\rootfs where <package> is a WSL distribution is the modern equivalent of %localappdata%\lxss--the packaged location is the new location for non-legacy distributions. They're subject to the same rules.

The problem here isn't using bind mounts, exactly. You're using a bind mount into a Windows volume, pointed at the WSL private data directory. Because you've set up docker using this guide, you're asking the linux docker client to tell the Windows docker daemon to run a linux utility (via LCOW) to manipulate the WSL files for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants