Docker volume mount doesn't exist

2019-07-02 09:52发布

I'm running Docker 1.11 on OS X and I'm trying to figure out where my local volumes are being written. I created a Docker volume by running docker volume create --name mysql. I then ran docker volume inspect mysql and it output the following:

[
    {
        "Name": "mysql",
        "Driver": "local",
        "Mountpoint": "/mnt/sda1/var/lib/docker/volumes/mysql/_data",
        "Labels": {}
    }
]

The issue is /mnt/sda1/var/lib/docker/volumes/mysql/_data doesn't actually exist on my machine. I thought maybe the issue was that it didn't actually get created until it was used by a container so I started a container by running docker run --name mysql -v mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mysql -P -d mysql:5.7 and then created a database in MySQL, but the mount point still doesn't exist. I even ran docker inspect mysql to ensure it's using the correct volume and got the following:

...
"Mounts": [
    {
        "Name": "mysql",
        "Source": "/mnt/sda1/var/lib/docker/volumes/mysql/_data",
        "Destination": "/var/lib/mysql",
        "Driver": "local",
        "Mode": "z",
        "RW": true,
        "Propagation": "rprivate"
    }
],
...

At this point I'm completely lost as to where the data is being written. What am I missing?

1条回答
一纸荒年 Trace。
2楼-- · 2019-07-02 10:46

Because Docker is based on Linux, it cannot run directly on Windows/OS X. Instead, it runs inside a VirtualBox virtual machine (a Docker Machine) that runs a Linux operating system. That's why when you install Docker Toolbox you see that VirtualBox is installed.

To see files and folders inside this virtual machine, use

docker-machine ssh default

default is the name of the default Docker Machine.

查看更多
登录 后发表回答