Originally published on docker.learnio.dev — part of the Docker fundamentals course. View this lesson on the original site.

Solution: healthcheck nginx

Compare your Dockerfile and commands with the academy folder.

GitHub example

Academy repo: 1-install-docker/healthcheck-nginx

Try it

git clone https://github.com/stuarttodd-dev/halfshellstudios-academy.git
cd halfshellstudios-academy/docker-fundamentals/1-install-docker/healthcheck-nginx
docker build -t nginx-hc:local .
docker run -d --name nginx-hc -p 127.0.0.1:8080:80 nginx-hc:local
docker inspect --format '{{json .State.Health}}' nginx-hc | head -c 400
curl -I http://127.0.0.1:8080
docker rm -f nginx-hc

Expected: Health.Status becomes healthy and curl returns 200.

If it goes wrong

  • Match the base image tag to the lesson (nginx:stable-alpine).
  • On Apple Silicon, if pull fails for a platform-specific tag, add --platform linux/amd64 only while debugging platform issues.

Remember

Ship the healthcheck in the image definition so every environment gets the same probe.

From Docker fundamentals — Install Docker, see the value, and learn the basics