Originally published on docker.learnio.dev — part of the Docker fundamentals course. View this lesson on the original site.
Three ways to check a container
“Running” is not the same as “healthy.” Build these habits early:
- Smoke test from outside:
curl(or a browser) against a published port. - Read logs:
docker logsfor startup errors. - Healthcheck in the Dockerfile: the engine marks the container unhealthy when an internal probe fails.
Optional fourth habit for PHP teams: run tests inside the image (docker run --rm your-app vendor/bin/phpunit) so CI and laptop share the same runtime.
See it
docker ps --filter name=hello-nginx
curl -I http://127.0.0.1:8080
docker logs hello-nginx
Example HEALTHCHECK in a Dockerfile:
HEALTHCHECK CMD curl -f http://localhost/ || exit 1
Try it
On any container you started in this chapter, run the three-step loop: status → HTTP → logs.
If it goes wrong
curlworks but healthcheck fails: the probe URL or tool inside the image may be wrong (Alpine images may not includecurluntil you install it).- Container “running” but app 500: logs usually show the real error.
Remember
Before you rebuild or rewrite code, check status, one real request, and recent logs.
From Docker fundamentals — Install Docker, see the value, and learn the basics