Managing Docker Images and Containers
Learn the everyday Docker commands to list, inspect, stop, remove, and clean up images and containers so you can keep your environment tidy.
Managing Docker Images and Containers is a free Docker & Kubernetes for Developers lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Docker & Kubernetes for Developers learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Images vs Containers
Two core concepts: an image is a read-only template (like a class), and a container is a running instance of it (like an object). One image, many containers.
Listing Images
List the images on your machine with docker images. Each row shows the repository, tag, id, and size.
docker imagesListing Containers
docker ps shows running containers; add -a to include stopped ones too.
docker ps -aInspecting a Container
docker inspect prints detailed JSON about a container or image — its config, network, mounts, and more.
docker inspect my_containerViewing Logs
Read a container's output with docker logs. Add the -f flag to follow the stream live, like tail -f.
docker logs -f my_containerStopping and Starting
docker stop halts a container gracefully (SIGTERM, then SIGKILL after a grace period) and docker start brings it back.
docker stop my_container
docker start my_containerRemoving a Container
Delete a stopped container with docker rm. You can't remove a running one unless you force it with -f.
docker rm my_containerRemoving an Image
Remove an image with docker rmi. It fails if any container still references it, so clear those dependent containers first.
docker rmi nginx:latestRunning a Command Inside
docker exec runs a command inside a running container. With -it you get an interactive shell to poke around.
docker exec -it my_container shCleaning Up with prune
Stopped containers and dangling images pile up over time. docker system prune reclaims all that space in one command.
docker system pruneNaming Containers
Give a container a friendly handle with --name at run time, so you reference it by name instead of a random id.
docker run --name web -d nginxQuick Check
Test your Docker management knowledge.
Recap
Recap: list with docker images and ps -a, dig in with inspect and logs, control lifecycle via stop/start/rm/rmi, and clean up with system prune.
Frequently asked questions
Is the “Managing Docker Images and Containers” lesson free?
Yes — the full text of “Managing Docker Images and Containers” is free to read here on the web, and the Docker & Kubernetes for Developers course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Docker & Kubernetes for Developers course, upgrade to CoddyKit PRO.
What will I learn in “Managing Docker Images and Containers”?
Learn the everyday Docker commands to list, inspect, stop, remove, and clean up images and containers so you can keep your environment tidy. You practise Docker & Kubernetes for Developers with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Docker & Kubernetes for Developers?
No prior experience is required. Docker & Kubernetes for Developers on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Managing Docker Images and Containers” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Docker & Kubernetes for Developers lesson?
Yes. Every Docker & Kubernetes for Developers lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Introduction to Containerization
- Installing Docker & Basic Commands
- Running Your First Container
- Managing Docker Images and Containers