Access Docker volume Mountpoint with Docker for Ma

2020-06-12 22:31发布

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

标签: docker
1条回答
女痞
2楼-- · 2020-06-12 22:45

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.

查看更多
登录 后发表回答