Portal | Level: L0: Entry | Topics: Docker / Containers | Domain: Kubernetes
Docker - Skill Check¶
Mental model (bottom-up)¶
Containers are just processes with namespaces (isolation) and cgroups (limits). Images are layers stacked by a union filesystem.
Visual stack¶
[Container ] a process with isolated view of files/net/pids
|
[Namespaces ] pid/net/mount/user isolation
|
[cgroups ] CPU/mem/io limits and accounting
|
[Image layers ] union FS layers + copy-on-write
|
[Host kernel ] shared kernel (not a VM)
Glossary¶
- namespace - isolation boundary for processes
- cgroup - resource limiting/accounting
- image layer - filesystem diff added by a Dockerfile step
- copy-on-write - writes go to top layer; lower layers stay immutable
- volume - persistent storage outside container lifecycle
- bridge network - default NATed container network
Roadmap core (easy -> hard)¶
- What is a container (really)?
- Isolated process via namespaces + cgroups (not a VM).
- Image vs container?
- Image = immutable template; container = running instance.
- Why "works on my machine" happens?
- Missing deps/env/config; container pins runtime and deps.
- What is a volume used for?
- Persist data outside container lifecycle.
- Port mapping meaning?
- Host port forwards to container port.
Builds & images (easy -> hard)¶
- Why
.dockerignore? - Shrinks build context; avoids leaking secrets; faster builds.
- Layer caching: what breaks it?
- Changing earlier steps or copying changing files too early.
- Why multi-stage builds?
- Smaller, safer runtime images by excluding build tools.
- Base image choice matters because?
- Size + CVE surface + libc/compatibility.
COPYvsADD?- Prefer
COPY;ADDhas extra magic (tar/URL) you usually don't want. - Pin image versions?
- Avoid surprise breakage; easier rollbacks.
Runtime, networking, storage (easy -> hard)¶
- Bridge network does what?
- NATed container network with port publishing.
- Host network tradeoff?
- Faster/simpler but less isolation.
- Bind mount vs named volume?
- Bind uses host path; named is Docker-managed.
- Why containers "lose data"?
- Container FS is ephemeral unless using volumes.
- Healthcheck value?
- Lets orchestrators detect unhealthy containers.
Security & reliability (easy -> hard)¶
- Why run as non-root?
- Reduce impact of container breakouts and app bugs.
- What are Linux capabilities?
- Fine-grained privileges; drop all then add minimal needed.
- Read-only filesystem pattern?
- Mount app FS read-only; writable dirs via tmpfs/volumes.
- Secrets injection best practice?
- Runtime secrets store; avoid baking secrets into images/env.
- Supply chain baseline?
- Scan images, pin digests, signed artifacts, minimal base.
Debugging (easy -> hard)¶
- First 3 commands when a container fails?
docker ps -a,docker logs <id>,docker inspect <id>.- How do you "get a shell"?
docker exec -it <id> sh(or bash if present).- Why
exit 137shows up? - SIGKILL (often OOM-killed).
- How do you reproduce locally?
- Run the same image/tag with same env/volumes; compare.
Visual guide (multi-stage)¶
Cleanup / teardown¶
- Remove resources you created:
docker rm -f <container>;docker rmi <image>;docker volume rm <vol>;docker network rm <net>- Nuke unused stuff (careful):
docker system prune -a(this is destructive).
Key correctness notes¶
- Multi-stage builds let you use multiple
FROMstages and copy only what you need into the final image. - The common outcome is a smaller, more secure final image — build-time tools and secrets from earlier stages are excluded.
Sources¶
- Docker official docs: build best practices, multi-stage builds.
- https://docs.docker.com/build/building/multi-stage/
Wiki Navigation¶
Related Content¶
- AWS ECS (Topic Pack, L2) — Docker / Containers
- Case Study: CI Pipeline Fails — Docker Layer Cache Corruption (Case Study, L2) — Docker / Containers
- Case Study: Container Vuln Scanner False Positive Blocks Deploy (Case Study, L2) — Docker / Containers
- Case Study: ImagePullBackOff Registry Auth (Case Study, L1) — Docker / Containers
- Container Images (Topic Pack, L1) — Docker / Containers
- Containers Deep Dive (Topic Pack, L1) — Docker / Containers
- Deep Dive: Containers How They Really Work (deep_dive, L2) — Docker / Containers
- Deep Dive: Docker Image Internals (deep_dive, L2) — Docker / Containers
- Docker (Topic Pack, L1) — Docker / Containers
- Docker Basics Flashcards (CLI) (flashcard_deck, L1) — Docker / Containers
Pages that link here¶
- Container Images
- Containers - How They Really Work
- Containers Deep Dive
- DevOps Tooling Domain
- Docker
- Docker Drills
- Docker Image Internals
- Level 2: Container Platform
- Scenario: Docker Container Won't Start in Production
- Symptoms
- Symptoms: CI Pipeline Fails, Docker Layer Cache Corruption, Fix Is Registry GC
- Symptoms: Container Image Vuln Scanner False Positive, Blocks Deploy Pipeline
- Track: Containers