Docker Community Forums

Share and learn in the Docker community.

Shared file between Docker container and Windows for WSL 2

I fon’t see instructions anywhere how to access files in my container from Windows (or Windows files from my container, or just creating a shared folder between them) if I am using WSL 2. Could you please help me? Thank you!

I leave this link here for others to see where we discussed this question.

Some additional details:

Normally, a container’s filesystem is available from the Linux host as root, although changing files that way is not recommended. Installing Docker manually in a WSL 2 system works th same way. When you instal Docker Desktop For Windows with the WSL 2 backend the filesystem is a little more complicated. Accessing files inside the container is easier by entering the container (at least it was for me) using docker exec

You could probably use Visual Studio Code which has a very good Docker support so you can browse the containers and their filesystem. To share Windows filesystem with containers you can use bind mounts which is often incorrectly referred to as “volumes” which is a little different but similar to the “local volumes”.

Bind mount is what you saw in the other topic I linked above, although it is more on Windows because the Windows filesystem has to be mounted to the VM (WSL 2 in this case) first.