Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker volume mount doesn't exist

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?

like image 417
bokoxev Avatar asked Apr 24 '16 23:04

bokoxev


People also ask

What is Workdir in Dockerfile?

The WORKDIR command is used to define the working directory of a Docker container at any given time. The command is specified in the Dockerfile. Any RUN , CMD , ADD , COPY , or ENTRYPOINT command will be executed in the specified working directory.

What is bind mount a volume in Docker?

Bind mounts have been around since the early days of Docker. Bind mounts have limited functionality compared to volumes. When you use a bind mount, a file or directory on the host machine is mounted into a container. The file or directory is referenced by its absolute path on the host machine.


2 Answers

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.

like image 133
Xiongbing Jin Avatar answered Oct 15 '22 14:10

Xiongbing Jin


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
like image 23
Flavio Avatar answered Oct 15 '22 14:10

Flavio