Docker:将目录从一个容器装入另一个容器 [英] Docker: Mount directory from one container to another

查看:552
本文介绍了Docker:将目录从一个容器装入另一个容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个码头图像。 Docker映像中的一个(从第一个容器)运行时,会生成一些文件,这些文件需要另一个容器使用。



我可以这样做吗?

解决方案

您可以共享数据而不使用主机的目录(container1 ==> container2):

  docker run -v / data / myfolder  - -name container1 image-name-1 
docker run --volumes-from container1 image-name-2


I have two docker images. One of the docker image (from first container), when ran, generates some files, which needs to be consumed by the another container.

Can I do this?

解决方案

Rene's answer works, but you could share data without using the host's directory (container1 ==> container2):

docker run -v /data/myfolder --name container1 image-name-1
docker run --volumes-from container1 image-name-2

这篇关于Docker:将目录从一个容器装入另一个容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆