[英]how to share folder between host os and docker container
I have created a volume of a docker image. 我已经创建了一个docker镜像卷。 The docker image is:
泊坞窗图片为:
REPOSITORY TAG IMAGE ID CREATED SIZE
gcr.io/tensorflow/tensorflow latest-gpu 7f09e75cdc12 4 months ago 1.289 GB
And the container volume is: 容器体积为:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
e99c80d2d53e gcr.io/tensorflow/tensorflow:latest-gpu "/run_jupyter.sh" 21 hours ago Up 11 minutes 6006/tcp, 0.0.0.0:8888->8888/tcp deep
I need to share a folder between the host Ubuntu 16.04
OS and the docker container. 我需要在主机
Ubuntu 16.04
OS和Docker容器之间共享一个文件夹。 I ran this command for doing this: 为此,我运行了以下命令:
docker run -v /home/cortana/deep-learning/:/home gcr.io/tensorflow/tensorflow:latest-gpu
docker运行-v / home / cortana / deep-learning /:/ home gcr.io/tensorflow/tensorflow:latest-gpu
This didnt lead to the folder being loaded into the container deep
. 这并没有导致文件夹被
deep
加载到容器中。 I dont know what to do after this and am really new to the container stuff in docker. 我不知道该怎么办,对Docker中的容器来说真的很陌生。 Please explain your answer a bit too.
请也解释一下您的答案。
EDIT: I deleted the container and then ran these commands: 编辑:我删除了容器,然后运行以下命令:
docker run -v /home/cortana/deep-learning/:/home gcr.io/tensorflow/tensorflow:latest-gpu
nvidia-docker run -p 8888:8888 --name deep gcr.io/tensorflow/tensorflow:latest-gpu
nvidia-docker exec -it deep bash
There is no folder called deep-learning
in the /home/
folder in the container. 容器中的
/home/
文件夹中没有名为“ deep-learning
”的文件夹。 What have I done wrong here? 我在这里做错了什么?
There's no API I'm aware of to change the mounted volumes on a running container. 我不知道要更改正在运行的容器上已装入的卷的API。 You destroy the existing container (
docker stop
and docker rm
) and create a new one with the proper configuration ( docker run
). 您销毁现有容器(
docker stop
和docker rm
)并创建具有正确配置的新容器( docker run
)。 If you find yourself trying to maintain a single container, upgrading apps inside the container or with data inside, odds are good that you're trying to recreate a VM rather than isolating a process, which is an anti-pattern. 如果您发现自己尝试维护一个容器,升级容器中的应用程序或内部包含数据,则很可能尝试重新创建VM而不是隔离进程(这是一种反模式)。
From your edit, you didn't create the /home/deep-learning folder, you created the /home folder. 通过编辑,您没有创建/ home / deep-learning文件夹,而是创建了/ home文件夹。 You also appear to be creating a second container named deep without any volume mounts and exec'ing into that one.
您似乎还正在创建一个名为deep的第二个容器,没有任何卷挂载并执行到该容器中。 To make a container with the /home/deep-learning volume mount and the name deep, run it like:
要使容器具有/ home / deep-learning卷安装和名称deep,请按以下方式运行它:
docker run -v /home/cortana/deep-learning:/home/deep-learning \
-p 8888:8888 --name deep gcr.io/tensorflow/tensorflow:latest-gpu
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.