I created a REST service in the Spring Boot.
application.properties file says that app should run on port 8081 (server.port=8081)
Image is made with Dockerfile:
FROM eclipse-temurin:17-jdk-alpine
WORKDIR /app
COPY target/*.jar /app/app.jar
COPY startup.sh /app/startup.sh
RUN chmod +x startup.sh
ENTRYPOINT ["./startup.sh"]
Shell script actually do nothing more than running an app.
Later, I run my container with docker-compose up and an error appears. The docker-compose.yaml file looks like that:
services:
service1:
image: test_image
ports:
- "8082:8081"
healthcheck:
test: "curl --fail localhost:8082/actuator/health | grep UP || exit 1"
interval: 10s
timeout: 3s
retries: 3
So I understand that port from a container (8081) should be mapped to 8082 and actuator should check if it's healthy. Unfortunately, when I run curl localhost:8082/actuator/health in the console, I got {status:UP}, but when I check docker ps -a I see an "unhealthy" information. Really don't know why this happens and what is the difference between asking curl directly and asking curl in the way this is specified in the docker-compose.yaml file.