docker构建镜像时出现 ADD failed: file not found in build context or excluded by .dockerignore: stat usr/local/dockerjdk8/jdk-8u291-linux-x64.tar.gz: file does not exist

docker构建镜像时出现 ADD failed: file not found in build context or excluded by .dockerignore: stat usr/local/dockerjdk8/jdk-8u291-linux-x64.tar.gz: file does not exist

如果你的配置或者写的路径都没问题的话 那这个方法也许会有用:

我的Dockerfile文件

 1 #依赖镜像名称和ID
 2 FROM centos:7
 3 #指定镜像创建者信息
 4 MAINTAINER ITCAST
 5 #切换工作目录
 6 WORKDIR /usr
 7 RUN mkdir  /usr/local/java
 8 #ADD 是相对路径jar,把java添加到容器中
 9 ADD jdk-8u291-linux-x64.tar.gz /usr/local/java/
10 #配置java环境变量
11 ENV JAVA_HOME /usr/local/java/jdk1.8.0_291
12 ENV JRE_HOME $JAVA_HOME/jre
13 ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
14 ENV PATH $JAVA_HOME/bin:$PATH

 

进行编辑  .dockerignore  注意前面的 . 

1 vim .dockerignore

进行编辑  保存

docker构建镜像时出现 ADD failed: file not found in build context or excluded by .dockerignore: stat usr/local/dockerjdk8/jdk-8u291-linux-x64.tar.gz: file does not exist

进行构建

1 docker build -t ‘jdk1.8‘ . 

docker构建镜像时出现 ADD failed: file not found in build context or excluded by .dockerignore: stat usr/local/dockerjdk8/jdk-8u291-linux-x64.tar.gz: file does not exist

问题解决

docker构建镜像时出现 ADD failed: file not found in build context or excluded by .dockerignore: stat usr/local/dockerjdk8/jdk-8u291-linux-x64.tar.gz: file does not exist

上一篇:linux系统下的rz、sz详解


下一篇:Mac手势神器BAB:Better And Better for Mac