Dockerfile 将 war 复制到本地链接卷
Dockerfile copying war to local linked volume
我有一个笔记应用程序,我正在使用 Maven 应用程序中的 Docker 文件构建它。
我想将神器 note-1.0.war 复制到本地链接卷到像 webapps 这样的文件夹。到目前为止,我在 Docker 文件中有以下内容:
FROM maven:latest
MAINTAINER Sonam <emailme@gmail.com>
RUN apt-get update
WORKDIR /code
#Prepare by downloading dependencies
ADD pom.xml /code/pom.xml
RUN ["mvn", "dependency:resolve"]
RUN ["mvn", "verify"]
#Adding source, compile and package into a fat jar
ADD src /code/src
RUN ["mvn", "clean"]
#RUN ["mvn", "install"]
RUN ["mvn", "install", "-Dmaven.test.skip=true"]
RUN mkdir webapps
COPY note-1.0.war webapps
#COPY code/target/note-1.0.war webapps
不幸的是,我一直在 COPY 语句中看到 "no such file or directory"。以下是在 Docker hub 上构建的错误:
...
---> bd555aecadbd
Removing intermediate container 69c09945f954
Step 11 : RUN mkdir webapps
---> Running in 3d114c40caee
---> 184903fa1041
Removing intermediate container 3d114c40caee
Step 12 : COPY note-1.0.war webapps
lstat note-1.0.war: no such file or directory
如何将 war 文件复制到我在
中执行的 "webapps" 文件夹中
RUN mkdir webapps
谢谢
COPY 指令从 <src>
复制新文件或目录,并将它们添加到容器的文件系统路径 <dest>
。
在您的示例中,docker 构建正在与 Dockerfile 相同的目录中寻找 note-1.0.war
。
如果我理解你的意图,你想在 Dockerfile 中从以前的 RUN
构建的图像中复制一个文件。
所以你应该使用像
这样的东西
RUN cp /code/target/note-1.0.war /code/webapps
我有一个笔记应用程序,我正在使用 Maven 应用程序中的 Docker 文件构建它。 我想将神器 note-1.0.war 复制到本地链接卷到像 webapps 这样的文件夹。到目前为止,我在 Docker 文件中有以下内容:
FROM maven:latest
MAINTAINER Sonam <emailme@gmail.com>
RUN apt-get update
WORKDIR /code
#Prepare by downloading dependencies
ADD pom.xml /code/pom.xml
RUN ["mvn", "dependency:resolve"]
RUN ["mvn", "verify"]
#Adding source, compile and package into a fat jar
ADD src /code/src
RUN ["mvn", "clean"]
#RUN ["mvn", "install"]
RUN ["mvn", "install", "-Dmaven.test.skip=true"]
RUN mkdir webapps
COPY note-1.0.war webapps
#COPY code/target/note-1.0.war webapps
不幸的是,我一直在 COPY 语句中看到 "no such file or directory"。以下是在 Docker hub 上构建的错误:
...
---> bd555aecadbd
Removing intermediate container 69c09945f954
Step 11 : RUN mkdir webapps
---> Running in 3d114c40caee
---> 184903fa1041
Removing intermediate container 3d114c40caee
Step 12 : COPY note-1.0.war webapps
lstat note-1.0.war: no such file or directory
如何将 war 文件复制到我在
中执行的 "webapps" 文件夹中RUN mkdir webapps
谢谢
COPY 指令从 <src>
复制新文件或目录,并将它们添加到容器的文件系统路径 <dest>
。
在您的示例中,docker 构建正在与 Dockerfile 相同的目录中寻找 note-1.0.war
。
如果我理解你的意图,你想在 Dockerfile 中从以前的 RUN
构建的图像中复制一个文件。
所以你应该使用像
RUN cp /code/target/note-1.0.war /code/webapps