Images vs Containers
Beginner
Overview
An image is a read-only template (your app plus its dependencies). A container is a running instance of an image — you can start many containers from one image.
docker pull downloads an image from a registry like Docker Hub. docker run creates and starts a container from it. docker ps lists running containers.
Containers are ephemeral: when one stops, changes inside it are lost unless you used a volume (covered later).
Cheatsheet
docker pull nginxDownload an imagedocker run -d -p 8080:80 nginxRun detached, map a portdocker psList running containersdocker ps -aList all containers, including stoppeddocker imagesList local imagesdocker stop <id>Stop a running containerTry it
A safe, simulated terminal. Run the suggested commands to see typical output.
simulated terminal
Type a command and press Enter, or click a suggestion below to run it.
Quick quiz
1. What is the relationship between an image and a container?
2. Which flag runs a container in the background?