我想在我的Docker镜像中包含一些JAR文件。我使用的是fabric8 maven插件的内联汇编特性。
下面是POM中的依赖项:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>${activemq.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>${org.json.version}</version>
<type>jar</type>
</dependency>下面是fabribc8插件的内联程序集:
<assembly>
<inline>
<id>copy-jars</id>
<dependencySets>
<dependencySet>
<includes>
<include>*</include>
</includes>
<outputDirectory>/opt/apache-jmeter-5.1.1/lib</outputDirectory>
</dependencySet>
</dependencySets>
</inline>
</assembly>JAR被复制到target/docker/...目录。截图:

我构建镜像,运行容器,并进入其中。但是,这个JAR不见了。
bash-4.4# ls -l /opt/apache-jmeter-5.1.1/lib/*active*
ls: /opt/apache-jmeter-5.1.1/lib/*active*: No such file or directory插件中有一个警告:[WARNING] DOCKER> Dockerfile /load-testing/Dockerfile does not contain an ADD or COPY directive to include assembly created at maven. Ignoring assembly.
我必须使用副本将文件从复制到Docker镜像中吗?我不是从插件免费得到的?或者我只是配置错了什么?
发布于 2021-05-29 00:32:37
我在尝试外部Dockerfile时也遇到了这个问题。程序集仅将其复制到目标文件夹,您仍需要在Dockerfile中使用COPY来获取它。所以你是对的,你似乎两者都需要。
如果你只需要罐子,你也可以在你的pom中使用这个。
<assemblies>
<assembly>
<descriptorRef>artifact-with-dependencies</descriptorRef>
</assembly>
</assemblies>但您仍然需要将它们复制到Dockerfile中,如下所示(如果您没有在程序集中提供名称,则maven是默认的文件夹名称)
COPY maven/ /opt/apache-jmeter-5.1.1/lib/https://stackoverflow.com/questions/66002243
复制相似问题