jenkins 处理对{}的请求时捕获到I/O异常(java. io. IOException)->unix://localhost:80:没有这样的文件或目录-从Dockerfile构建映像时

ldioqlga  于 2022-11-28  发布在  Jenkins
关注(0)|答案(2)|浏览(514)

我想使用Jenkins中的Dockerfile为maven项目创建一个映像。这是一个 Spring 启动项目。我已经将Jenkins作为Docker容器运行。我正在使用windows 10。
我的停靠文件是:

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"]

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>

在Jenkins·多克的设定中是:

我还选择了选项Expose daemon on tcp://localhost:2375 without TLS在docker桌面。
但我得到的错误

[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]

我找到了这个问题的解决方案。我得到了一些解决方案,即设置Docker主机URI。我已经设置了它,并附上了上面的图像。
我该如何解决这个问题呢?先谢谢了。

xienkqul

xienkqul1#

当一个进程试图写入Docker守护进程套接字,但它缺少权限时,就会发生这种情况。
检查/var/run/docker.sock对于试图创建docker映像的用户是否可以访问。特别是,默认情况下,只有root用户和组具有写入docker.socket的权限,因此尝试执行chmod o+w /var/run/docker.sock以允许其他用户写入docker守护进程socket,然后问题应该就解决了。

fruv7luv

fruv7luv2#

这对我在Fedora上很有效-以root身份运行

export DOCKER_HOST=unix:///var/run/docker.sock
 service docker restart
 mvn clean install -DskipTests

相关问题