Open LukeOwlclaw opened 2 years ago
Hi there,
From compose v3 you can implement a healthcheck. I haven't looked at the image, but if curl is available, you can do something like:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5080"]
interval: 1m30s
timeout: 10s
retries: 3
start_period: 40s
I dont know which one is port 5080 for you (SMTP/HTTP), but: SMTP gives back rc 1 HTTP gives back rc 22 (as its 404) Unavailable port gives back rc 7
With this in mind, you can setup a healthcheck one-liner. For example:
healthcheck:
test: ["CMD", "curl -f localhost:8081 > /dev/null 2>&1; if [[ $? -eq 22 ]]; then exit 0; else exit 1; fi"]
interval: 1m30s
timeout: 10s
retries: 3
start_period: 40s
https://docs.docker.com/compose/compose-file/compose-file-v3/#healthcheck
@Re4zOon thank you for sharing. I agree that this is a valid alternative.
I am using
fake-smtp-server
with docker-compose for development. I noticed that it takes some time until port 5080 is actually ready to serve connections.What do you think about including
wait-for-it.sh
in the Dockerfile?For a quick howto, see: https://selahattinunlu.medium.com/how-to-wait-for-a-container-to-be-ready-757bc1a86468