2

I'm, trying to build a docker image with ./mvnw -DskipTests spring-boot:build-image using spring boot 2.4.1 and java 11 (openjdk version "11.0.9" 2020-10-20 LTS) on RHEL7.

I do this on a host behind a strict firewall so I have to fetch the build- and runimage from a private repo. I have configured the spring-boot-maven-plugin to use this repo:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <docker>
            <builderRegistry>
                <username>my-username</username>
                <password>xxx</password>
                <url>https://my-mirror.com</url>
                <email>kaj.hejer@usit.uio.no</email>
            </builderRegistry>
        </docker>


        <image>
            <builder>my-mirror.com/library/docker.io-paketobuildpacks-builder:base</builder>
            <runImage>my-mirror.com/library/docker.io-paketobuildpacks-run:base</runImage>
            <name>my-mirror.com/my-group/my-app:latest</name>
            <verboseLogging>true</verboseLogging>
        </image>
    </configuration>
</plugin>

The build fails with

[INFO]  > Pulling builder image 'my-mirror.com/library/docker.io-paketobuildpacks-builder:base' 100%
[INFO]  > Pulled builder image 'my-mirror.com/library/docker.io-paketobuildpacks-builder@sha256:cf90221a33966e42f8b1960123dea4406c65fc6a410142ded573ed850ccc313b'
[INFO]  > Pulling run image 'my-mirror.com/library/docker.io-paketobuildpacks-run:base' 100%
[INFO]  > Pulled run image 'my-mirror.com/library/docker.io-paketobuildpacks-run@sha256:56fb7587103da155db6d4f9434fd7e2f9e45d7540a062847fd84e9132a28101b'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.090 s
[INFO] Finished at: 2020-12-17T08:36:48+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:build-image (default-cli) on project my-app: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:build-image failed: Missing 'io.buildpacks.stack.id' stack label -> [Help 1]
[ERROR] 

When I try to build a docker image the same way but without the configuration block for the spring-boot-maven-plugin on my mac which is not behind a firewall it works just fine.

Can it be SELinux releated in some way? sudo journalctl -f don't list anything when running the mvnw command.

Thanks in advance for any input or ideas!

-Kaj :)

Kaj Hejer
  • 955
  • 4
  • 18
  • https://stackoverflow.com/questions/65344886/unable-to-build-image-using-gradle-bootbuildimage-in-offline-environment might be releated. – Kaj Hejer Dec 17 '20 at 17:09
  • I created an issue on this, see https://github.com/spring-projects/spring-boot/issues/24641 – Kaj Hejer Jan 04 '21 at 12:42

1 Answers1

0

On https://github.com/spring-projects/spring-boot/issues/24641 we found that I used the tag base instead of base-cnb. With tag base-cnb it worked fine.

Now I got a [creator] ERROR: failed to initialize docker client: failed to connect to docker socket: dial unix /var/run/docker.sock: connect: permission denied but that is not related to this question.

Kaj Hejer
  • 955
  • 4
  • 18
  • Did you come up with a solution for the `connect: permission denied` error? https://github.com/spring-projects/spring-boot/issues/25853 appears to be related. – Scott Frederick Mar 31 '21 at 22:02
  • @ScottFrederick I think this was releated to running on RHEL7 which has a old dockerversion. An alternativ can be to use podman, but running podman as a other user than root is not streigt forward. We ended up using a traditional Dockerfile. – Kaj Hejer Apr 01 '21 at 13:57
  • Any luck @KajHejer other than `Dockerfile`? Assuming you haven't tried since? I'm trying to build a Spring Boot v2.5.1 project in a Kubernetes container. This is a privileged container running as root with a Docker unix socket mounted. I can run all `docker` commands including building images just fine, but `spring-boot:build-image` bombs with the error in your description: `ERROR: failed to initialize docker client: failed to connect to docker socket: dial unix /var/run/docker.sock: connect: connection refused`. – wsams Jun 24 '21 at 19:05
  • @wsams Sorry, have not looked any more into that. – Kaj Hejer Aug 02 '21 at 14:32
  • @wsams did you have any luck getting Spring boot to build happy? I am in exactly the same boat you are. – astropcr Jan 26 '22 at 05:11
  • @wsams We ended up using a Dockerfile. – Kaj Hejer Jan 27 '22 at 07:11