I have docker-compose file with volumes section for given container:
video-streaming:
image: video-streaming
build:
context: ./video-streaming
dockerfile: Dockerfile-dev
container_name: video-streaming
volumes:
- /tmp/history/npm-cache:/root/.npm:z
I’m running docker on windows and image is linux based.
When I enter container and add file to /root/.npm and then close the container and run it again then the file is still there so this volume works. But the question is where can I find it’s location on Windows host?
2
Answers
You should find the volumes in
C:ProgramDatadockervolumes
. The filename will be a hash, which you can check withdocker inspect
.If not, then note that you are simply mounting a host directory
/tmp/history/npm-cache
to your container. This directory is your volume.When using docker for windows the question is if you are using the old Docker Toolbox or the newer ones that use WSL/WSL2
Docker Desktop configured Linux Containers and WSL/WSL2
The docker engine is actually not running on the windows, but inside the WSL instance, docker desktop makes docker commands available on the windows for ease of use.
So the volumes are probably inside that WSL instance (linux)
you can find out what WSL instances you have by typing
wsl -l
in powershell.their file-system is available in
\wsl$
path on windows.In your case, the volume is not named, its in the exact location you specified for it.
/tmp/history/npm-cache
but inside the WSL instance that docker engine is installed on.Through WSL
in powershell write
wsl ls /tmp/history
, you should seenpm-cache
there.wsl
command allows piping linux commands that will be run on the actual linux wsl instance (default one) which is probably the one running the docker engine.alternatively, you can connect to that linux by just typing
wsl
and going to that pathcd /tmp/history
once inside the wsl instance you can write
explorer.exe .
to open explorer in that location (on windows)notice that the path will always start with
\wsl$
so you can go to that path on windows and see all of you wsl instances and their file-systems, try to search for "npm-cache" in explorer, you might find it.via Docker commands
docker volume ls
will give you all of the available volumes. yours is not named, so its probably one of the ‘UUID’ ones. you can inspect each one to find its location (probably still inside the wsl instance)docker volume inspact {the-uuid-of-the-volume}
ones you inspect it, you will see each volume has a Mountpoint field which points to the location of the volume (inside the wsl instance)
unnamed volumes are created with different permissions from your user, so you might need sudo to interact with them via the wsl terminal.
if its through windows file explorer on
\wsl$
you might not need extra permissions.