Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven Docker COPY只复制一个子目录,而不是整个构建上下文_Maven_Docker_Build_Copy_Quarkus - Fatal编程技术网

Maven Docker COPY只复制一个子目录,而不是整个构建上下文

Maven Docker COPY只复制一个子目录,而不是整个构建上下文,maven,docker,build,copy,quarkus,Maven,Docker,Build,Copy,Quarkus,我创建了一个虚拟项目,使用Java中的“Maven原型”。我想将整个构建上下文复制到Docker容器中 当我在当前目录中执行ls-al时,我得到以下结果: drwxr-xr-x 12 my.user staff 384 19 Aug 15:57 . drwxr-xr-x 12 my.user staff 384 19 Aug 15:39 .. -rw-r--r-- 1 my.user staff 53 19 Aug 15:39 .dockerignore -rw

我创建了一个虚拟项目,使用Java中的“Maven原型”。我想将整个构建上下文复制到Docker容器中

当我在当前目录中执行
ls-al
时,我得到以下结果:

drwxr-xr-x  12 my.user  staff    384 19 Aug 15:57 .
drwxr-xr-x  12 my.user  staff    384 19 Aug 15:39 ..
-rw-r--r--   1 my.user  staff     53 19 Aug 15:39 .dockerignore
-rw-r--r--   1 my.user  staff    295 19 Aug 15:39 .gitignore
drwxr-xr-x   7 my.user  staff    224 19 Aug 15:45 .idea
drwxr-xr-x   3 my.user  staff     96 19 Aug 15:39 .mvn
-rw-r--r--   1 my.user  staff     78 19 Aug 15:57 Dockerfile
-rwxrwxr-x   1 my.user  staff  10078 19 Aug 15:39 mvnw
-rw-rw-r--   1 my.user  staff   6609 19 Aug 15:39 mvnw.cmd
-rw-r--r--   1 my.user  staff   3691 19 Aug 15:39 pom.xml
drwxr-xr-x   4 my.user  staff    128 19 Aug 15:39 src
drwxr-xr-x  15 my.user  staff    480 19 Aug 15:40 target
这是我的
Dockerfile

FROM maven:3-jdk-11-slim
WORKDIR /home/mvn
COPY ./ .
RUN ls -al
RUN mvn verify
不幸的是,只有目标文件夹被复制。这是docker build的结果输出。:

Sending build context to Docker daemon  8.425MB
Step 1/5 : FROM maven:3-jdk-11-slim
 ---> b67032e30f89
Step 2/5 : WORKDIR /home/mvn
 ---> Running in 90dc6171c4be
Removing intermediate container 90dc6171c4be
 ---> 3cf149c09c43
Step 3/5 : COPY ./ .
 ---> bf0869cf8577
Step 4/5 : RUN ls -al
 ---> Running in 733891348a3c
total 12
drwxr-xr-x 1 root root 4096 Aug 19 14:00 .
drwxr-xr-x 1 root root 4096 Aug 19 14:00 ..
drwxr-xr-x 3 root root 4096 Aug 19 14:00 target
Removing intermediate container 733891348a3c
 ---> f425feab5580
Step 5/5 : RUN mvn verify
 ---> Running in 29e2dae052f6
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.078 s
[INFO] Finished at: 2019-08-19T14:00:51Z
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/mvn). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
The command '/bin/sh -c mvn verify' returned a non-zero code: 1

这里可能有什么错误?

Quarkus Maven原型添加了一个
.dockrignore
文件。其中只有
target
文件夹未从Docker中排除。因此,只复制了
目标
文件夹。

您的
.dockrignore
中添加了一些内容。@atline谢谢,这就是解决方案!您是否愿意将您的解决方案@HaroldL.Brown发布给未来的用户,让他们了解需要什么来修复它?