Docker:从父目录添加文件 [英] Docker: adding a file from a parent directory

查看:1172
本文介绍了Docker:从父目录添加文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Dockerfile 我有:

 添加。 ./../myapp.war / opt / tomcat7 / webapps / 

该文件以 ls ../../ myapp.war 返回正确的文件,但是当我执行 sudo docker build -t myapp。我有:

 步骤1:ADD ../../myapp.war / opt / tomcat7 / webapps / 
2014/07/02 19:18:09 ../../myapp.war:没有这样的文件或目录

有人知道为什么和如何正确执行?

解决方案

不幸的是(为了实际和安全原因我想),如果要添加/复制本地内容,它必须位于与 Dockerfile 相同的根路径下。



文档


< src>路径必须在构建的上下文之内;你
不能ADD ../something/something,因为docker
build的第一步是将上下文目录(和子目录)发送到
docker守护进程。


编辑:现在有一个选项( -f )来设置你的Docker文件的路径;它可以用来实现你想要的,见@Boedy的回应nelow。


In my Dockerfile I've got :

ADD ../../myapp.war /opt/tomcat7/webapps/

That file exists as ls ../../myapp.war returns me the correct file but when I execute sudo docker build -t myapp . I've got :

Step 1 : ADD ../../myapp.war /opt/tomcat7/webapps/
2014/07/02 19:18:09 ../../myapp.war: no such file or directory

Does somebody know why and how to do it correctly?

解决方案

Unfortunately, (for practical and security reasons I guess), if you want to add/copy local content, it must be located under the same root path than the Dockerfile.

From the documentation:

The <src> path must be inside the context of the build; you cannot ADD ../something/something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.

EDIT: There's now an option (-f) to set the path of your Dockerfile ; it can be used to achieve what you want, see @Boedy 's response nelow.

这篇关于Docker:从父目录添加文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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