Skip to content

Instantly share code, notes, and snippets.

@pplmx
Last active March 1, 2023 10:21
Show Gist options
  • Save pplmx/04565c030bc95c00a1ad56da08c4096e to your computer and use it in GitHub Desktop.
Save pplmx/04565c030bc95c00a1ad56da08c4096e to your computer and use it in GitHub Desktop.
docker compose healthcheck
version: Compose specification
services:
proxy:
image: nginx
container_name: nginx
restart: always
ports:
- "8080:80"
healthcheck:
# 1. if curl or wget is not available, maybe try this
# https://github.com/dart-lang/dart-docker/issues/58#issuecomment-1410663799
# 2. maybe you can implement a custom healthcheck based on your project language(Golang, Python, etc.)
# 3. The following two ways are both ok, but you must ensure the command curl is installed
#test: curl -f http://proxy:8080 || exit 1
test: ["CMD", "curl", "-f", "http://proxy:8080"]
interval: 5s
timeout: 5s
retries: 6
start_period: 20s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment