0
votes

I am using Spring-Boot 2.4.4 on a Docker environment managed by a docker-compose.yml file and visualized with portainer. I am building my Docker images with the Spring-Boot build-in builder (with paketo-buildpacks)

mvn spring-boot:build-image

I want to get my Docker container be monitored with spring-actuator. So I add the maven dependency and I got the desired result when I run my application locally and accessing the certain page:

http://localhost:8080/actuator/health

Since I am using the Spring-Boot build-in Docker image builder I have no Dockerfile to add a healthpoint. When I add the healtheck in my docker-compose.yml, the wget command is not found:

    healthcheck:
      test: wget --spider --quiet 'http://localhost:8080/actuator/health/' || exit 1
      interval: 10s
      timeout: 3s
      retries: 10
      start_period: 10s

What am I doing wrong? I could not find any documentation on the web. I thought that Spring-Boot would be able to detect spring-actuator on its own, but I think that it doesn´t.

2

2 Answers

0
votes

Neither wget nor curl commands are included in base image that is used to run Spring Boot application. Maybe you can mount another util volume: https://stackoverflow.com/a/65854305/8335251

Or, just write another lightweight java application for requesting health actuator, map the result into exit code. Then pack it into jar, build another image with jar package based on Spring Boot application image. After that, health check could run with java -jar command.

0
votes

You can switch the builder that is used when you package up your container image. See the image customization settings here.

The default builder is paketobuildpacks/builder:base, which has a run image that does not include curl or wget. You could switch the builder to paketobuildpacks/builder:full and you should have curl (possibly also wget, I'm not sure off the top of my head).

The trade-off here is that the run image is larger, so the size of your built images is going to go up. The full image has quite a bit of stuff and weights in around 1G, compared to around 100M for the base image.

Docker is smart about downloading the layers, so if you have 50 apps based on the same full builder image, it's not going to cause 50G to be downloaded. Docker (and other container runtimes) only downloads the layers it doesn't have already so that extra gig is basically a one-time downloaded. Ultimately, you'll have to determine if the convenience of having curl is worth the extra size in the images.