Docker & Containers
Volumes, bind mounts and environment variables
Removing a container deletes its writable layer; data in separate volumes or bind mounts can remain. Volumes keep data alive past the container, and environment variables feed it settings without rebuilding the image.
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
- Images, tags and registriesBeginner · 5 min
An image is a read-only package; a container is one running copy of it. Tags are movable labels on images, which is why 'it worked yesterday with latest' is a real bug.
- Writing a Dockerfile: FROM, COPY, RUN, CMDBeginner · 6 min
A Dockerfile is a short recipe that turns your code into an image. Five instructions cover most files, and the hard part is knowing which ones run when you build and…
- Why did my container exit? Exit codes 0, 1, 137 and 143Beginner · 5 min
Every stopped container leaves a number behind. Read it, and a mystery restart loop becomes one of three or four causes you can test in a minute.
- PID 1, signal forwarding and why docker stop takes 10 secondsBeginner · 5 min
docker stop waits exactly ten seconds and then kills your service. The ten seconds are not Docker being slow: your program is PID 1, and the kernel treats PID 1…
- Debugging a running container: exec, logs, inspect, nsenterBeginner · 5 min
The container is Up, the health check is green and users still get errors. Debugging it means asking the container, the kernel and the host in a fixed order, and having…
- Layer caching: order your Dockerfile for fast buildsBeginner · 5 min
A Node.js service rebuilds in over four minutes after every one-line edit because the dependency install runs again. The fix is moving two lines, and it works only once…