Docker & Containers
Publishing ports with -p, and the database you exposed by accident
Docker port publishing can expose a container service through the host. One missing address in -p turns a local test database into one reachable from the internet.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in Docker & Containers
- HEALTHCHECK and restart policiesBeginner · 5 min
A service that needs 100 seconds to start gets labelled unhealthy at second 90. The health check defaults are for fast apps, and an unhealthy label restarts nothing by…
- Bridge networking and container DNSBeginner · 5 min
Two containers sit on the same host, both running, and one cannot find the other by name. The default network has no name lookup, and the fix takes one command.
- Compose: run a multi-container appBeginner · 5 min
A README with fourteen docker run commands, in the right order, with the right flags, is how a new teammate loses a morning. A 25-line file replaces it.
- Layered filesystemBeginner · 4 min
Explain how image layers and copy-on-write work, and why a deleted file still takes space in an earlier layer and why copy order affects build caching.
- BuildKit cache mountsIntermediate · 4 min
Explain how BuildKit cache mounts keep package caches across builds without storing them in the image, and where that cache lives, including on a fresh CI runner.
- Multi stage buildsIntermediate · 4 min
Explain how multi-stage Dockerfiles keep build tools out of the final image, how COPY --from chooses what the runtime stage receives, and when a broad copy undoes it.