Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Docker volume Mountpoint with Docker for Mac

Tags:

docker

I'm using Docker for mac and I want to find where are the volume created by Docker.

# Create volume
docker volume create --name volume-name

# Create container binding this volume
docker run -dti -v volume-name:/data --name deb debian:jessie

# Create a file in container:/data
docker exec -ti deb touch /data/test.txt

# Find the Mountpoint
docker volume inspect volume-name
# Get :
# [
#     {
#         "Name": "volume-name",
#         "Driver": "local",
#         "Mountpoint": "/var/lib/docker/volumes/volume-name/_data",
#         "Labels": {},
#         "Scope": "local"
#     }
# ]

When I am using Docker on Linux, I can run

ls /var/lib/docker/volumes/volume-name/_data

and see the test.txt file

But, on macOs I don't know where I can find this Mountpoint.

I found this post (Docker volume mount doesn't exist) but the author seems to use boot2docker and I'm not.

docker-machine ssh default
# Host does not exist: "default"

Can someone help me to find this Mountpoint on macOs using Docker for Mac

like image 951
vincent_chapron Avatar asked Dec 21 '16 23:12

vincent_chapron


People also ask

How do I access Docker volume data on Mac?

docker. docker/Data/vms/0/tty to get into the vm and then navigate to the folder to see the volumes.

Where are volumes stored Docker Mac?

Unlike bind mount, where you can mount any directory from your host, volumes are stored in a single location (most likely /var/lib/docker/volumes/ on unix systems) and greatly facilitates managing data (backup, restore, and migration).


1 Answers

I finally found the solution to get access of the linux virtual machine using docker for mac

sudo screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
cd /var/lib/docker/volumes/volume-name/_data
mv test.txt /Users/path/to/destination

By default some directories are shared (/Users, /Volumes, ...), Then I can move my data volume directory to my mac from the vm.

like image 121
vincent_chapron Avatar answered Oct 01 '22 00:10

vincent_chapron