Docker COPY:没有这样的文件或目录

时间:2018-10-30 14:06:33

标签: docker copy

我正在尝试运行执行maven构建的docker构建。

这是我的Dockerfile:

FROM maven:3.5.4-jdk-8-slim

COPY * /myapp/src/

WORKDIR /myapp/src/

RUN mvn clean package

RUN ls -la target
RUN ls -la ./target

COPY ./target/myapp.jar ../
COPY config.yml ../

WORKDIR /myapp/

CMD ["java", "-jar", "myapp.jar"]

我收到的问题是

COPY failed: stat /var/snap/docker/common/var-lib-docker/tmp/docker-builder185918822/target/myapp.jar: no such file or directory

我添加了两个ls语句用于调试,这是输出:

...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:27 min
[INFO] Finished at: 2018-10-30T13:59:42Z
[INFO] ------------------------------------------------------------------------

Removing intermediate container 5c0f369c5f9d
 ---> d2b36b5070e3
Step 5/10 : RUN ls -la target
 ---> Running in 4de6062b1573
total 19104
drwxr-xr-x 4 root root     4096 Oct 30 13:59 .
drwxr-xr-x 5 root root     4096 Oct 30 13:59 ..
drwxr-xr-x 2 root root     4096 Oct 30 13:59 classes
drwxr-xr-x 2 root root     4096 Oct 30 13:59 maven-archiver
-rw-r--r-- 1 root root 19538983 Oct 30 13:59 myapp.jar
-rw-r--r-- 1 root root     3294 Oct 30 13:59 original-myapp.jar
Removing intermediate container 4de6062b1573
 ---> 47f4a7534ffb
Step 6/10 : RUN ls -la ./target
 ---> Running in 55c68b1fbbe9
total 19104
drwxr-xr-x 4 root root     4096 Oct 30 13:59 .
drwxr-xr-x 5 root root     4096 Oct 30 13:59 ..
drwxr-xr-x 2 root root     4096 Oct 30 13:59 classes
drwxr-xr-x 2 root root     4096 Oct 30 13:59 maven-archiver
-rw-r--r-- 1 root root 19538983 Oct 30 13:59 myapp.jar
-rw-r--r-- 1 root root     3294 Oct 30 13:59 original-myapp.jar
Removing intermediate container 55c68b1fbbe9
 ---> bbc8a395474c
Step 7/10 : COPY ./target/myapp.jar ../
COPY failed: stat /var/snap/docker/common/var-lib-docker/tmp/docker-builder185918822/target/myapp.jar: no such file or directory

从两个ls命令的输出中可以看到,jar文件在那里。为什么Docker无法找到它?

0 个答案:

没有答案