medium · dockerfile/missing-healthcheck

Missing HEALTHCHECK instruction

Services that EXPOSE a port should declare a HEALTHCHECK so orchestrators can detect unhealthy processes. CLI images without EXPOSE are skipped.

Why it breaks the cache

Orchestrators cannot distinguish a healthy service from a stuck process.

Bad Dockerfile

FROM node:18
EXPOSE 8080
CMD ["node", "server.js"]

Good Dockerfile

FROM node:18
EXPOSE 8080
HEALTHCHECK CMD curl -f http://localhost:8080/health || exit 1
CMD ["node", "server.js"]

CLI

layerlint rules explain missing-healthcheck

All docs · Download