Coder Social home page Coder Social logo

Comments (13)

scottfrederick avatar scottfrederick commented on April 30, 2024

The Spring Boot Gradle plugin documentation includes an example of configuring the plugin for use with podman.

The podman compatibility mode that creates a symlink for /var/run/docker.sock is enough for the Gradle plugin code to access the podman daemon, as demonstrated by the fact that the builder images are being pulled successfully. Processes inside the builder container also need to access the daemon, and this is the part that is not working for you (the error is coming from the creator process in the builder lifecycle).

Please try configuring the plugin as documented and let us know if that works.

from spring-boot.

ThomasVitale avatar ThomasVitale commented on April 30, 2024

@scottfrederick I experienced the same issue. If I downgrade Spring Boot from 3.2.3 to 3.1.9, the bootBuildImage task completes successfully.

Also, I tried out the same test using Maven instead of Gradle, and the spring-boot:build-image command completes successfully for both 3.2.3 and 3.1.9.

So, it seems to be a problem specific to Spring Boot 3.2.x with Gradle.

from spring-boot.

acisternino avatar acisternino commented on April 30, 2024

Apologies, I completely forgot that section of the manual.
However, even with those changes the result is still an error.

Before providing more details I'd like to note that the changes suggested by the manual are a bit misleading for people on macOS.

First, the following line is valid only for Linux. On macOS /run doesn't exist and this could lead to misunderstandings.

host.set("unix:///run/user/1000/podman/podman.sock")

The podman command for finding the socket is also wrong on macOS:

$ podman info --format='{{.Host.RemoteSocket.Path}}'
/run/podman/podman.sock
$ ls -l /run/podman/podman.sock
ls: /run/podman/podman.sock: No such file or directory

In the following comments I will highlight the specific problems I am still having.

from spring-boot.

acisternino avatar acisternino commented on April 30, 2024

With host set to:

host.set("unix:///var/run/docker.sock")

I get (abbreviated):

$ ./gradlew clean bootBuildImage

> Task :bootBuildImage
Building image 'docker.io/library/spring-podman:0.0.1-SNAPSHOT'

 > Pulling builder image 'docker.io/paketobuildpacks/builder-jammy-base:latest' ..................................................
 > Pulled builder image 'docker.io/paketobuildpacks/builder-jammy-base@sha256:94593b2ad54362e1256da43631661d3dad936a177609a3d297fc638e87c6ee91'
 > Pulling run image 'docker.io/paketobuildpacks/run-jammy-base:latest' ..................................................
 > Pulled run image 'docker.io/paketobuildpacks/run-jammy-base@sha256:c2bc9ac828642aee2376a649ef5affd6912507c739247a40086bcae6d62a8b41'
 > Executing lifecycle version v0.18.5
 > Using build cache volume 'pack-cache-f19174dfe539.build'

 > Running creator
    [creator]     ===> ANALYZING
    [creator]     ERROR: failed to initialize analyzer: getting previous image: 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

> Task :bootBuildImage FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootBuildImage'.
> Builder lifecycle 'creator' failed with status code 1

BUILD FAILED in 6s
6 actionable tasks: 6 executed

$ ls -l /var/run/docker.sock
lrwxr-xr-x  1 root  daemon  75 Mar  6 08:52 /var/run/docker.sock -> /Users/andrea.cisternino/.local/share/containers/podman/machine/podman.sock

from spring-boot.

acisternino avatar acisternino commented on April 30, 2024

This is interesting.

With host set to:

host.set("unix:///Users/andrea.cisternino/.local/share/containers/podman/machine/podman.sock")

I get:

$ ./gradlew clean bootBuildImage

> Task :bootBuildImage
Building image 'docker.io/library/spring-podman:0.0.1-SNAPSHOT'

 > Pulling builder image 'docker.io/paketobuildpacks/builder-jammy-base:latest' ..................................................
 > Pulled builder image 'docker.io/paketobuildpacks/builder-jammy-base@sha256:94593b2ad54362e1256da43631661d3dad936a177609a3d297fc638e87c6ee91'
 > Pulling run image 'docker.io/paketobuildpacks/run-jammy-base:latest' ..................................................
 > Pulled run image 'docker.io/paketobuildpacks/run-jammy-base@sha256:c2bc9ac828642aee2376a649ef5affd6912507c739247a40086bcae6d62a8b41'
 > Executing lifecycle version v0.18.5
 > Using build cache volume 'pack-cache-f19174dfe539.build'

 > Running creator

> Task :bootBuildImage FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootBuildImage'.
> Docker API call to '/Users/andrea.cisternino/.local/share/containers/podman/machine/podman.sock/v1.24/containers/create' failed with status code 500 "Internal Server Error" and message "container create: statfs /Users/andrea.cisternino/.local/share/containers/podman/machine/podman.sock: operation not supported"

BUILD FAILED in 4s

$ ls -l /Users/andrea.cisternino/.local/share/containers/podman/machine/podman.sock
lrwxr-xr-x@ 1 andrea.cisternino  staff  80 Feb  2 09:23 /Users/andrea.cisternino/.local/share/containers/podman/machine/podman.sock -> /Users/andrea.cisternino/.local/share/containers/podman/machine/qemu/podman.sock

from spring-boot.

acisternino avatar acisternino commented on April 30, 2024

Finally, with host set to:

host.set("unix:///Users/andrea.cisternino/.local/share/containers/podman/machine/qemu/podman.sock")

I get the exact same result as above.

For info:

$ ls -l /Users/andrea.cisternino/.local/share/containers/podman/machine/qemu/podman.sock
srw-------  1 andrea.cisternino  staff  0 Mar  6 08:52 /Users/andrea.cisternino/.local/share/containers/podman/machine/qemu/podman.sock

from spring-boot.

awsp avatar awsp commented on April 30, 2024

I also happened to get the exact same error when using 3.2.2 using Gradle Kotlin.
OS: macOS Ventura 13.6
Podman: 1.7.1

* What went wrong:
Execution failed for task ':bootBuildImage'.
> Docker API call to '/Users/awsp/.local/share/containers/podman/machine/qemu/podman.sock/v1.24/containers/create' failed with status code 500 "Internal Server Error" and message "container create: statfs /Users/awsp/.local/share/containers/podman/machine/qemu/podman.sock: operation not supported"

image

from spring-boot.

scottfrederick avatar scottfrederick commented on April 30, 2024

There appears to be a few different things going on here.

First, there is the issue of Podman Desktop's Docker compatibility mode.

Podman is configured to have docker compatibility activated. This is visible in Podman Desktop's dashboard.
These are the sockets and their properties:

As stated above, this compatibility mode socket symlink works for the code in the Spring Boot plugins that connect to the daemon using the Docker socket. However, the /var/run/docker.sock socket is not set up correctly for the CNB lifecycle code that runs inside the builder image, leading to the permission denied errors. I suspect this is not a configuration that can be easily supported with CNB buidpacks, and we should recommend using the explicit Podman remote configuration instead.

Second, there is the issue of the operation not supported errors from the /containers/create API shown by @acisternino and @awsp when the Podman socket is explicitly configured. We'll have to debug more into this on a macOS machine to figure out what's going on there.

The podman command for finding the socket is also wrong on macOS:

The only other guidance I've seen in the Podman documentation is to set the socket address to $XDG_RUNTIME_DIR/podman/podman.sock, but I don't think this is portable to macOS either. We might just need to qualify that documentation tip as applicable to Linux only if Podman does not provide a reliable way to get the socket path on macOS or Windows.

Also, I tried out the same test using Maven instead of Gradle, and the spring-boot:build-image command completes successfully for both 3.2.3 and 3.1.9.
So, it seems to be a problem specific to Spring Boot 3.2.x with Gradle.

@ThomasVitale This is very surprising, since the code that is specific to the Maven and Gradle plugins is very thin and the vast majority of the code that builds images is the same between the two plugins. We'll have to do more testing to see if we can reproduce this difference.

If anyone is able to test their Podman on macOS configuration using the pack CLI along with the Boot plugins, I'd be curious to know if pack shows the same behavior.

from spring-boot.

sdeleuze avatar sdeleuze commented on April 30, 2024

Seems to work for me when enabling Docker compatibility and installing podman-mac-helper.

from spring-boot.

acisternino avatar acisternino commented on April 30, 2024

Interesting. @sdeleuze I have checked my environment and I have podman-mac-helper installed and running.

I went through the documentation and I can confirm that all the steps in the Verification paragraph are indeed OK on my machine but the build still fails with the same errors as above.

@scottfrederick I am no pack expert but I tried to use it to build an image for my super simple demo project but both my attempts failed for unclear reasons after downloading the Gradle distribution.. This is what I tried:

$ pack build spring-podman --builder=gcr.io/buildpacks/builder --env GOOGLE_RUNTIME_VERSION=21
$ pack build spring-podman --builder=paketobuildpacks/builder-jammy-full --env BP_JVM_VERSION=21

from spring-boot.

scottfrederick avatar scottfrederick commented on April 30, 2024

We will need to debug this further to see why users are having different results with Podman Desktop and podman-mac-helper, but we've created a wiki page in the Spring Boot GitHub repo to capture some of the items here that can be covered with documentation. See https://github.com/spring-projects/spring-boot/wiki/Building-OCI-Images-with-Spring-Boot#podman-support. Feel free to comment with feedback on this documentation.

from spring-boot.

scottfrederick avatar scottfrederick commented on April 30, 2024

I am no pack expert but I tried to use it to build an image for my super simple demo project but both my attempts failed for unclear reasons after downloading the Gradle distribution.. This is what I tried:

@acisternino There is some information here about testing with the pack CLI. Building from a jar file as shown there should eliminate the problems with downloading a Gradle distribution. If you can try this again with your Podman setup that would be helpful.

from spring-boot.

acisternino avatar acisternino commented on April 30, 2024

Hi @scottfrederick,

I have tried using pack following the instructions in the link above and it worked.

This is what I tried from inside the project (named spring-podman) directory:

$ ./gradlew clean bootJar

$ pack build --builder paketobuildpacks/builder-jammy-base:latest \
             --path build/libs/spring-podman-0.0.1-SNAPSHOT.jar \
             --env BP_JVM_VERSION=21 \
             spring-podman

from spring-boot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.