I'm currently working on a microservice project using docker-compose. So I was adding health checks to my containers. But except mysql every thing else stays unhealthy but I don't know why.
Here is my docker-compose.yml file.
version: "3"
services:
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
container_name: kafka
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 52.78.52.254
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- zookeeper
mysql:
image: mysql
container_name: mysql
ports:
- "3306:3306"
volumes:
- ./data/mysql:/var/lib/mysql:rw
environment:
- MYSQL_ROOT_PASSWORD=dnjscksdn98@
- MYSQL_DATABASE=explanet_dev
- MYSQL_USER=alex
- MYSQL_PASSWORD=dnjscksdn98@
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "mysql", "-u$$MYSQL_USER", "-p$$MYSQL_ROOT_PASSWORD" ]
interval: 30s
timeout: 10s
retries: 3
api-gateway:
container_name: api-gateway
ports:
- "80:80"
build:
context: ./api-gateway
args:
ENVIRONMENT: dev
dockerfile: Dockerfile
healthcheck:
test: [ "CMD", "curl", "-f", "http://api-gateway/health-check" ]
interval: 30s
timeout: 10s
retries: 3
depends_on:
- mysql
chatting-service:
container_name: chatting-service
ports:
- "8080:8080"
build:
context: ./chatting-service
args:
ENVIRONMENT: dev
dockerfile: Dockerfile
healthcheck:
test: [ "CMD", "curl", "-f", "http://chatting-service:8080/health-check" ]
interval: 30s
timeout: 10s
retries: 3
depends_on:
- mysql
- kafka
- api-gateway
And if I type docker inspect ${any container name}
it shows like this in the State
.
"Health": {
"Status": "unhealthy",
"FailingStreak": 12,
"Log": [
{
"Start": "2020-12-01T04:47:28.090046668Z",
"End": "2020-12-01T04:47:28.158193366Z",
"ExitCode": -1,
"Output": "OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused \"exec: \\\"curl\\\": executable file not found in $PATH\": unknown"
},
{
"Start": "2020-12-01T04:47:58.162656864Z",
"End": "2020-12-01T04:47:58.233280387Z",
"ExitCode": -1,
"Output": "OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused \"exec: \\\"curl\\\": executable file not found in $PATH\": unknown"
},
{
"Start": "2020-12-01T04:48:28.238446336Z",
"End": "2020-12-01T04:48:28.325520772Z",
"ExitCode": -1,
"Output": "OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused \"exec: \\\"curl\\\": executable file not found in $PATH\": unknown"
},
{
"Start": "2020-12-01T04:48:58.330407168Z",
"End": "2020-12-01T04:48:58.398503364Z",
"ExitCode": -1,
"Output": "OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused \"exec: \\\"curl\\\": executable file not found in $PATH\": unknown"
},
{
"Start": "2020-12-01T04:49:28.403163576Z",
"End": "2020-12-01T04:49:28.477627297Z",
"ExitCode": -1,
"Output": "OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused \"exec: \\\"curl\\\": executable file not found in $PATH\": unknown"
}
]
}
My java Dockerfile looks like this.
FROM adoptopenjdk/openjdk11:alpine-jre
COPY build/libs/base-service-0.0.1-SNAPSHOT.jar base-service.jar
ARG ENVIRONMENT
ENV SPRING_PROFILES_ACTIVE=${ENVIRONMENT}
ENTRYPOINT ["java", "-jar", "base-service.jar"]
I'm currently running on Ubuntu 20.04 server. Is there any solutions?
Hello the error message is pretty clear, you can't run curl for health check because it's not included in base image you use, you need to install it.
Exemple for alpine images
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.