大网数据广告活动
服务器运维问答

Docker: Mount directory from one container to a specific path in another

· 52CE 我爱测

When we use "-v" argument in "docker run" command, we can specify {src path from host}:{path in container}, e.g docker run -v /var/volumns/v1:/var/docker/v1ref ... But, how about mounting a data-only container? docker run --volum…

问题原文

原帖链接 · Wissam Roujoulah · CC BY-SA 3.0

When we use "-v" argument in "docker run" command, we can specify {src path from host}:{path in container}, e.g

docker run -v /var/volumns/v1:/var/docker/v1ref ...

But, how about mounting a data-only container?

docker run --volumes-from data-only-container:<here is mode, ro or rw>

How I can achieve the same when using "-v"? Can I mount it to a specific folder?

已采纳解答

原帖链接 · Carlos Rafael Ramirez · CC BY-SA 3.0

I am afraid that the direct answer to your question is: no, you can't. volumes-from import the volumes exactly as they are defined in the other container.

Since docker 1.9 volume containers are being replaced with named volumes as the recommended practice. With named volumes you can mount it wherever you want :

docker volume create --name data
docker run -v data:/var/docker/v1ref ...

Regards

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-11-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。