spotify docker/dockerfile maven 插件 [错误] 复制失败
spotify docker/dockerfile maven plugin [ERROR] Copy failed
我正在尝试在我的项目上执行 mvn clean package docker:build
它失败并出现以下错误
ERROR] Failed to execute goal
com.spotify:docker-maven-plugin:1.1.0:build (default-cli) on project
mma-access-management-auth-server: Exception caught: COPY failed: stat
/var/lib/docker/tmp/docker-builder181535370/mma-access-management-app-1.0.0-SNAPSHOT.jar:
no such file or directory -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal com.spotify:docker-maven-plugin:1.1.0:build (default-cli)
on project mma-access-management-auth-server: Exception caught
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356) Caused by:
org.apache.maven.plugin.MojoExecutionException: Exception caught
at com.spotify.docker.AbstractDockerMojo.execute (AbstractDockerMojo.java:151)
at com.spotify.docker.BuildMojo.execute (BuildMojo.java:324)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356) Caused by:
com.spotify.docker.client.exceptions.DockerException: COPY failed:
stat
/var/lib/docker/tmp/docker-builder181535370/mma-access-management-app-1.0.0-SNAPSHOT.jar:
no such file or directory
这是我的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mma</groupId>
<artifactId>mma-access-management-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>mma-access-management-auth-server</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mma-access-management-rest-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.8.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<imageName>mma/${project.artifactId}</imageName>
<imageTags>
<imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<dockerDirectory>dockerfile</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
这是我的 Dockerfile
FROM openjdk:8u131-jdk-alpine
ENV targetDir /usr/local/access-management-app-1.0.0-SNAPSHOT.jar
ENV srcDir .
ENV jarFile mma-access-management-app-1.0.0-SNAPSHOT.jar
RUN mkdir ${targetDir}
COPY ${srcDir}/${jarFile} ${targetDir}
WORKDIR ${targetDir}
CMD ["java", "-jar", "mma-access-management-app-1.0.0-SNAPSHOT.jar"]
EXPOSE 8080/tcp
我不知道哪里出了问题。我还尝试使用 spotify 的 dockerfile 插件,但也失败了。
maven 构建的 jar 文件 ${project.build.finalName}.jar
与您在 Dockerfile
中定义的不同。
调整Dockerfile中指定的jar文件名,使其与maven构建的jar匹配即可。
FROM openjdk:8u131-jdk-alpine
ENV targetDir /usr/local/access-management-auth-server-1.0.0-SNAPSHOT.jar
ENV srcDir .
ENV jarFile mma-access-management-auth-server-1.0.0-SNAPSHOT.jar
RUN mkdir ${targetDir}
COPY ${srcDir}/${jarFile} ${targetDir}
WORKDIR ${targetDir}
CMD ["java", "-jar", "mma-access-management-auth-server-1.0.0-SNAPSHOT.jar"]
EXPOSE 8080/tcp
看起来不像是 spotify 插件的问题。 docker 构建失败于
COPY ${srcDir}/${jarFile} ${targetDir}
我猜 srcDir
指向 src
文件夹,而 jar 将出现在 target
文件夹中。
我正在尝试在我的项目上执行 mvn clean package docker:build
它失败并出现以下错误
ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.1.0:build (default-cli) on project mma-access-management-auth-server: Exception caught: COPY failed: stat /var/lib/docker/tmp/docker-builder181535370/mma-access-management-app-1.0.0-SNAPSHOT.jar: no such file or directory -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:docker-maven-plugin:1.1.0:build (default-cli) on project mma-access-management-auth-server: Exception caught at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290) at org.apache.maven.cli.MavenCli.main (MavenCli.java:194) at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Exception caught at com.spotify.docker.AbstractDockerMojo.execute (AbstractDockerMojo.java:151) at com.spotify.docker.BuildMojo.execute (BuildMojo.java:324) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290) at org.apache.maven.cli.MavenCli.main (MavenCli.java:194) at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356) Caused by: com.spotify.docker.client.exceptions.DockerException: COPY failed: stat /var/lib/docker/tmp/docker-builder181535370/mma-access-management-app-1.0.0-SNAPSHOT.jar: no such file or directory
这是我的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mma</groupId>
<artifactId>mma-access-management-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>mma-access-management-auth-server</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mma-access-management-rest-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.8.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<imageName>mma/${project.artifactId}</imageName>
<imageTags>
<imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<dockerDirectory>dockerfile</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
这是我的 Dockerfile
FROM openjdk:8u131-jdk-alpine
ENV targetDir /usr/local/access-management-app-1.0.0-SNAPSHOT.jar
ENV srcDir .
ENV jarFile mma-access-management-app-1.0.0-SNAPSHOT.jar
RUN mkdir ${targetDir}
COPY ${srcDir}/${jarFile} ${targetDir}
WORKDIR ${targetDir}
CMD ["java", "-jar", "mma-access-management-app-1.0.0-SNAPSHOT.jar"]
EXPOSE 8080/tcp
我不知道哪里出了问题。我还尝试使用 spotify 的 dockerfile 插件,但也失败了。
maven 构建的 jar 文件 ${project.build.finalName}.jar
与您在 Dockerfile
中定义的不同。
调整Dockerfile中指定的jar文件名,使其与maven构建的jar匹配即可。
FROM openjdk:8u131-jdk-alpine
ENV targetDir /usr/local/access-management-auth-server-1.0.0-SNAPSHOT.jar
ENV srcDir .
ENV jarFile mma-access-management-auth-server-1.0.0-SNAPSHOT.jar
RUN mkdir ${targetDir}
COPY ${srcDir}/${jarFile} ${targetDir}
WORKDIR ${targetDir}
CMD ["java", "-jar", "mma-access-management-auth-server-1.0.0-SNAPSHOT.jar"]
EXPOSE 8080/tcp
看起来不像是 spotify 插件的问题。 docker 构建失败于
COPY ${srcDir}/${jarFile} ${targetDir}
我猜 srcDir
指向 src
文件夹,而 jar 将出现在 target
文件夹中。