首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >处理对{}->unix://localhost:80的请求时捕获到I/O异常(java.io.IOException):无此类文件或目录-when从Dockerfile构建镜像

处理对{}->unix://localhost:80的请求时捕获到I/O异常(java.io.IOException):无此类文件或目录-when从Dockerfile构建镜像
EN

Stack Overflow用户
提问于 2020-07-29 15:57:58
回答 1查看 1.3K关注 0票数 1

我想在Jenkins中使用Dockerfile为maven项目创建一个图像。这是一个spring boot项目。我已经将Jenkins作为码头容器运行了。我用的是windows10。

我的dockerfile是:

代码语言:javascript
运行
复制
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的插件部分是:

代码语言:javascript
运行
复制
 <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 docker设置为:

我还选择了docker桌面中的Expose daemon on tcp://localhost:2375 without TLS选项。

但是我得到了一个错误

代码语言:javascript
运行
复制
[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。我已经设置了它,并附上了上面的图像。

我该如何解决这个问题?提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-02-16 16:33:27

当进程试图写入docker守护程序套接字,但它缺乏权限时,就会发生这种情况。

检查尝试创建docker映像的用户是否可以访问/var/run/docker.sock。特别是,默认情况下,只有超级用户和组有权写入docker.socket,因此尝试执行chmod o+w /var/run/docker.sock,以便允许其他用户写入docker守护进程套接字,然后问题就会解决。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63148930

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档