Docker: images and containers
Image, container, registry, tag and daemon; the commands pull, run (-d, -p, -e, --name, --rm), ps, stop, start, rm, logs, exec, images and rmi; container states and port publishing.
- 30 cards
- 6 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- The steps
- Scenarios
- Understand
A few cards from the deck
Docker image: what is it?
Show the answer
A read-only template, built in layers, from which containers are created.
As many containers as wanted can be created from one image: it never changes, each container adds its own writable layer.
Which command starts nginx in the background, named web, reachable on the host's port 8080?
docker run -d --name web -p 8080:80 nginxdocker run -d --name web -p 80:8080 nginxdocker run -d --name web -e 8080:80 nginxdocker run --rm --name web -p 8080:80 nginx
Show the answer
docker run -d --name web -p 8080:80 nginx-ddetaches,--namenames,-p host:containerpublishes. nginx listens on 80 inside the container, hence8080:80. The variant without-dkeeps the terminal busy, and-esets an environment variable, not a port.With
-p 8080:80, port … of the host is forwarded to port … of the container.Show the answer
With
-p 8080:80, port 8080 of the host is forwarded to port 80 of the container.The order is always host then container.
-p 80:8080would do the opposite: open the host's port 80 towards a container listening on 8080.Docker container: what is it?
Show the answer
A running instance of an image: an isolated process with a writable layer of its own, deleted only along with the container.
Image and container are much like a class and an object: the template, then its instances.
A container's life cycle: which step comes after "
docker create --name web nginx→ the container exists, state created"?docker start web→ state runningdocker pause web→ state pauseddocker unpause web→ back to state runningdocker stop web→ state exited
Show the answer
docker start web→ state runningA container goes through created, running (or paused) then exited, and is only erased by
docker rm.docker runchains create and start.