12

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?

timcase
  • 455
  • 2
  • 4
  • 14
  • 4
    On OS X and Windows, Docker runs inside a virtual machine (Boot2Docker). The folder is inside that vm. You can login using `docker-machine ssh default` and then see it. – Xiongbing Jin Apr 24 '16 at 23:31
  • Damn, I knew it was something stupid I was missing. Do you want to post as an answer so I can mark it? – timcase Apr 24 '16 at 23:33

2 Answers2

16

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.

Xiongbing Jin
  • 11,779
  • 3
  • 47
  • 41
  • 3
    This is not true anymore. Now Docker for Mac and Docker for Windows exist. – Maksim Dec 17 '16 at 15:10
  • 1
    Docker for Windows is only available for 64bit Windows 10 Pro, Enterprise and Education (1511 November update, Build 10586 or later) as of December 2016 and answer is still true... "not true anymore" is exaggerated – Erdinç Çorbacı Dec 31 '16 at 02:25
  • Oh my word - yes - I had missed that key bit of information where there is another host running the show on Windows 7. It all makes a bit more sense now. How I am going to get it to behave the way I want... I dunno – paulecoyote Feb 03 '17 at 21:29
2

Docker 19.3.8

I've changed the mountpoint for a folder that I created in my Mac.

After that it worked.

$ mkdir volume_database
$ docker container run -it \
--volume=/volume_database:/volume_database debian
Flavio
  • 759
  • 1
  • 11
  • 24