【发布时间】:2022-06-17 22:56:51
【问题描述】:
我尝试使用 podman 使用 mvn spring-boot:build-image 创建图像,但得到了
[INFO] --- spring-boot-maven-plugin:2.7.0:build-image (default-cli) @ sample-spring-service ---
[INFO] Building image 'docker.io/library/sample-spring-service:1.0.0-SNAPSHOT'
[INFO]
[INFO] > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%
[INFO] > Pulled builder image 'docker.io/paketobuildpacks/builder@sha256:94e65320ba1682bc68cbbf1d4f63693bb62cc06c7077bfa3e3bccac7fdc10628'
[INFO] > Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' 100%
[INFO] > Pulled run image 'docker.io/paketobuildpacks/run@sha256:3e889016680c0e2ef1e8b1bfdad2d6d34966c860a53ccfcfb3e269d48ed65fed'
[INFO] > Executing lifecycle version v0.14.1
[INFO] > Using build cache volume 'pack-cache-744ddec35876.build'
[INFO]
[INFO] > Running creator
[INFO] [creator] ERROR: initializing analyzer: getting previous image: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info": dial unix /var/run/docker.sock: connect: permission denied
播客信息:
host:
arch: amd64
buildahVersion: 1.26.1
cgroupControllers:
...
version:
APIVersion: 4.1.0
Built: 1651853754
BuiltTime: Fri May 6 18:15:54 2022
GitCommit: ""
GoVersion: go1.18
Os: linux
OsArch: linux/amd64
Version: 4.1.0
我已经尝试了很多。设置 socket 权限,使用 root 运行 podman。与 docker 相同,运行良好。
podman create alpine ls 工作正常。
在我的 pom.xml 中我尝试过:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<docker>
<!-- <host>unix:///Users/mike/.local/share/containers/podman/machine/podman-machine-default/podman.sock</host>
<host>unix:///run/user/1000/podman/podman.sock</host>
-->
<bindHostToBuilder>true</bindHostToBuilder>
</docker>
</configuration>
</plugin>
有什么想法吗?
更新:
如果我在 pom.xml 中启用此行:
unix:///run/user/1000/podman/podman.sock
我明白了:
[INFO] --- spring-boot-maven-plugin:2.7.0:build-image (default-cli) @ sample-spring-service ---
[INFO] Building image 'docker.io/library/sample-spring-service:1.0.0-SNAPSHOT'
[INFO]
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%
【问题讨论】:
-
Maven 输出表明 Spring Boot 正在按预期与 podman 对话(拉取图像等)。 Boot 然后调用 CNB builder 镜像中的进程,容器中的进程也需要与 podman 对话。失败的是 CNB 构建器容器内的
creator进程。您设置的<bindHostToBuilder>true</bindHostToBuilder>应该将unix:///var/run/docker.sock绑定到构建器容器中配置的<docker><host>,但我不确定权限发生了什么。 -
您可以尝试使用 CNB 文档中描述的
packCLI 执行相同的操作吗?使用 Boot 构建 jar 后,您将执行pack build sample-spring-service -p target/sample-spring-service-1.0.0-SNAPSHOT.jar -B paketobuildpacks/builder:base之类的操作。 buildpacks.io/docs/app-developer-guide/building-on-podman -
如果我在 pom.xml 中启用这一行:
标签: spring-boot podman