首页 技术 正文
技术 2022年11月19日
0 收藏 581 点赞 3,361 浏览 1921 个字
17favorite

4

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?

docker

shareimprove this question asked Jul 2 ’14 at 17:24Docker: adding a file from a parent directoryAnthony O.

3,5103365

 
1  
Some workarounds superuser.com/questions/842642 – Günter Zöchbauer Nov 30 ’14 at 19:51

activeoldestvotes

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.

shareimprove this answer edited Jun 20 at 12:45   answered Jul 2 ’14 at 20:01Docker: adding a file from a parent directorymbarthelemy

5,56512228

 
5  
Is there a “clean” workaround for this? I’d rather not restructure my whole project directory just to accommodate this. – ben_frankly Nov 21 ’14 at 18:35
    
As said by @Günter, there is a workaround here superuser.com/a/842690/136024 … is it really “clean”? Well at least it’s a “workaround” 🙂 – Anthony O. Dec 2 ’14 at 8:39
    
See better answer from @Boedy stackoverflow.com/a/34300129/2950621 – nmgeek Jun 19 at 19:27

shareimprove this answer

answered Dec 15 ’15 at 21:54Docker: adding a file from a parent directoryBoedy

388515

 
    
Worked smoothly 😉 – Souciance Eqdam Rashti Mar 2 at 10:51
    
Thank you! This works fine on a local box, but Docker Hub fails to build the image since it tries to do it from its same directory (tbh, just what one would normally expect). Is there any way to do the same trick in Docker Hub? – Marcel Hernandez Mar 25 at 20:31
    
Not that I know of. You could push the image to the registry instead of using automated build. – Boedy Mar 29 at 9:15 
1  
This should be marked as the right answer – Courtland Caldwell Jun 15 at 19:09

volume pointing to the parent folder:

#docker-composer.ymlfoo:
build: foo
volumes:
- ./:/src/:ro

But I’m pretty sure the can be done playing with volumes in Dockerfile.

shareimprove this answer
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,565
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,413
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,186
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905