pam*_*mpa 3 java maven jenkins docker
我想在 Jenkins 中使用 Dockerfile 为 Maven 项目创建一个映像。这是一个 Spring Boot 项目。我已经将 Jenkins 作为 docker 容器运行。我使用的是 Windows 10。
我的 dockerfile 是:
FROM maven:3.5-jdk-8-alpine
WORKDIR /app
COPY pom.xml /app/
COPY Dockerfile /app/
RUN ["mvn", "package"]
FROM tomcat:9
EXPOSE 8087
COPY /app/target/*.war /usr/local/tomcat/webapps/
CMD ["catalina.sh","run"]
Run Code Online (Sandbox Code Playgroud)
pom.xml 的插件部分是:
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.example.restcurd.RestcurdApplication</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.10</version>
<executions>
<execution>
<id>build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>pomkiticat/${project.name}</repository>
<tag>${project.version}</tag>
<skipDockerInfo>true</skipDockerInfo>
<pullNewerImage>false</pullNewerImage>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
我还选择了 docker Desktop 中的选项Expose daemon on tcp://localhost:2375 without TLS
。
但我收到错误
[0m[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16:05 min
[INFO] Finished at: 2020-07-29T06:58:10Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.10:build (default) on project restcurd: Could not build image: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.io.IOException: No such file or 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]
Run Code Online (Sandbox Code Playgroud)
我找到了问题的解决方案。我得到了一些解决方案,即设置 Docker Host Uri 。我已经设置好了并附上了上面的图片。
我该如何解决这个问题?提前致谢。
fyc*_*cth 12
当进程尝试写入 docker 守护进程套接字但缺乏权限时,就会发生这种情况。
检查/var/run/docker.sock
尝试创建 docker 映像的用户是否可以访问。特别是,默认情况下只有 root 和该组有权写入 docker.socket,因此请尝试执行chmod o+w /var/run/docker.sock
以允许其他人写入 docker 守护进程套接字,然后问题就会消失。
归档时间: |
|
查看次数: |
9919 次 |
最近记录: |