Docker Community Forums

Share and learn in the Docker community.

Cannot see volume on the host

docker

(Marwan91) #1

Everything works as expected when I specify a specific directory for a volume, aka -v specific_directory:/workdir but if I just do -v /workdir - I do not see the host directory.

Commands:

docker run -it --name container-test -h CONTAINER -v /data debian /bin/bash

docker inspect container-test

results:

        "Mounts": [
            {
                "Name": "bc907b86e5da9a775107d007f6e60f58dfb26f09c6332a3d00aff4920540e80d",
                "Source": "/var/lib/docker/volumes/bc907b86e5da9a775107d007f6e60f58dfb26f09c6332a3d00aff4920540e80d/_data",
                "Destination": "/data",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],

Now when I try to go to the source, /va/lib/docker does not exist.

How can I access that source directory from the host?


(David Maze) #2

That’s totally normal. -v /workdir with no host path (and, for that matter, docker volume create to create named volumes) creates the storage in private Docker space that you can’t directly access.


(Marwan91) #3

Thanks, this makes sense. Unfortunately, most articles out on volumes walk you through cd'ing into /var/lib/docker to see your automatically created volume directory. So it just felt odd that I couldn’t follow along with that step. I’m assuming those tutorials are referring to a linux build of docker. Would be nice if the documentation mentioned that. Maybe it does and I didn’t catch it, but I did do some unsuccessful looking up which led me to asking a question here. Thanks!