简体   繁体   中英

How to mount an external volume to Docker container? OS X

Trying to mount an external volume on my mac (10.13) to a docker container.

I have a volume mounted: /Volumes/myvolume

I am trying to mount it to a docker container:

docker run -t --rm -v /Volumes/myvolume/foo:/opt/myvolume busybox ls /opt/myvolume

Prints nothing. If I change it to something on my default disk it works fine: docker run -t --rm -v /Users/Steve/foo:/opt/myvolume busy box ls /opt/myvolume Shows me my files.

Also, if I just mount the volume I can see the foo folder, but it's empty.

docker run -it --rm -v /Volumes/myvolume busybox
/ # cd /opt/myvolume
/ ls
/ foo
/ cd foo
/ ls
/ 

I've tried restarting docker. Going to try playing with different volume/mount types next..

UPDATE: It works fine on my colleagues machine! He is running 10.12 so hasn't upgraded yet. Maybe this has something to do with APFS in 10.13? I tried creating volumes of different filetypes to see if I could find one that worked, but none did :(

For security reasons, Docker for Mac does not allow to bind any volume to a docker container. In Docker's Preferences, there is a section "File Sharing" in which you can specify which directories (and their subdirectories) can be bound to containers:

Docker Mac文件共享的示例配置

The documentation link in the screenshot leads to the following documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM