Learn Docker
Understand images, containers, volumes and Dockerfiles well enough to debug them, not only to type the commands.
What you will practise
- Images versus containers
- Dockerfile instructions and layer caching
- Volumes and networking basics
- Safer, smaller images
Docker lesson
A short introduction to the ideas behind the quizzes, before you start practising.
Docker packages an application with everything it needs to run into a portable container. The core ideas to get right early are the difference between an image and a container, and how layers make builds fast or slow.
Key concepts
Images vs containers
An image is a read-only template built from a Dockerfile. A container is a running instance of that image, with its own writable layer on top. You can start many containers from the same image.
docker build -t my-app .
docker run -d -p 3000:3000 my-appDockerfile layers and caching
Each instruction in a Dockerfile creates a cached layer. Docker reuses a layer if nothing above it changed, so copying dependency files and installing them before copying the rest of your source keeps rebuilds fast.
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["node", "server.js"]Volumes for persistent data
A container’s writable layer disappears when the container is removed. Volumes (or bind mounts) let data like a database’s files live outside the container’s lifecycle, so it survives restarts and rebuilds.
docker run -d -v db_data:/var/lib/postgresql/data postgresNetworking between containers
Containers on the same user-defined network can reach each other by container name, without publishing ports to the host. Ports only need to be published (`-p`) when something outside Docker must reach the container.
docker network create app-net
docker run -d --network app-net --name db postgres
docker run -d --network app-net --name api my-api # can reach "db"Common mistakes
- Copying the entire project before installing dependencies, which invalidates the dependency-install cache layer on every code change.
- Expecting data written inside a container to survive after `docker rm`, without using a volume.
- Forgetting `-p host:container` and then being confused that a running container is unreachable from the host.
- Building large images by including build tools and source files that are not needed at runtime, instead of a multi-stage build.
Quick recap
- An image is a template; a container is a running instance of it.
- Order Dockerfile instructions from least to most frequently changing, to keep the build cache useful.
- Use volumes for anything that must outlive a container.
- Containers on the same network can reach each other by name; publish ports only when the host needs access.
Ready to test this? Take the Docker Basics quiz →
Roadmap
Work through the levels in order, or jump to where you are.
Docker quizzes
Interactive Docker challenges
Hands-on activities: find bugs, complete code, order steps and match concepts.
FAQ
Do I need Kubernetes knowledge?
No. These quizzes stay on single-host Docker.
Why learn Docker as a student?
Docker is the industry standard for shipping software. Knowing how to containerize your project makes it infinitely easier to share with recruiters or deploy to the cloud.
Do you cover Docker Compose?
Yes. Our intermediate quizzes cover multi-container setups and the basics of docker-compose.yml files.