What to do (如题)
要将D:\okok\from挂载至docker指定虚拟机(ubuntu18.04)指定目录/home/to中。
Wrong ways(对我而言)
试了不同斜杠方式:
1.
docker run -it --name ubuntu -v d:\okok\from:/home/to ubuntu:18.04
有位博主说TA可以,但我被报错Error response from daemon: invalid mode
2.
docker run -it --name ubuntu -v /d/okok/from/:/home/to ubuntu:18.04
好像很多人这样就行 但我依然不行。
然后from后面加不加斜杠都试了两种都不行。
Right answer
虚拟机设共享文件夹,在docker默认虚拟机上操作共享文件夹,再在对应虚拟集创建时把共享文件夹下的复制过去。
具体地:
在VM管理器中,打开设置,点击共享文件夹。
路径写对应路径:D:\okok\from
共享文件夹名称随便取一个:test1(建议不同名)
之后运行docker quickstart terminal
依次输入
docker-machine ssh
sudo su
cd /mnt
mkdir test
mount -t vboxsf test1 /mnt/test #所以上面建议不同名,如果同名都为test就会报错
最后在
docker run -v /mnt/test/:/home/to -it --name ubuntu2 ubuntu:18.04
这里的ubuntu虚拟机/home/to就相当于外部D:\okok\from了。