⚙️ Docker CLI Mastery: Understanding Containers From the Terminal


📅 Day 2 of My Docker Sprint
🚀 Quick Recap of Day 1
Yesterday I explored the history and motivation behind Docker, learned about the evolution from bare metal → VMs → containers, and ran my first docker run hello-world
command.
Today, it’s time to get our hands dirty with the Docker CLI — the terminal interface that gives us full power over containers, images, volumes, and more.
🧠 Why Learn the CLI First?
While Docker Desktop and GUI tools are available, real DevOps engineers live in the terminal. The CLI:
Offers full control
Works in CI/CD pipelines
Trains you for production environments
Makes automation possible
🔧 Key Docker CLI Commands I Practiced Today
1. docker --version
Check if Docker is installed and running:
docker --version
2. docker pull
Download an image from Docker Hub:
docker pull alpine
Alpine is a tiny Linux image (just ~5MB) great for testing.
3. docker images
List all downloaded images:
docker images
🔎 Output includes image name, tag, size, and ID.
4. docker run
Run a container from an image:
docker run alpine echo "Hello from container!"
📌 This runs Alpine and prints a message, then exits.
5. docker ps
List running containers:
docker ps
Add -a
to list all containers, even stopped ones:
docker ps -a
6. docker stop
& docker rm
Stop and remove containers:
docker stop <container_id>
docker rm <container_id>
7. docker rmi
Remove an image:
docker rmi alpine
8. docker exec
Run commands inside a running container:
docker exec -it <container_id> sh
Opens a shell inside the container 🔥
💥 Key Concepts I Learned Today
Image: A blueprint for the container (like a snapshot)
Container: A running instance of an image
-it
flag: Interactive + pseudo-TTY (lets you type into the container)Ephemeral nature: Containers are stateless by default unless volumes are used
💡 Mistakes I Made
Forgot
-it
, so my shell exited immediately 😅Confused image ID with container ID
Tried to stop a container that had already exited
But that’s the beauty of learning in public — you document the bugs, too!
🔁 What’s Next (Day 3 Preview)
Tomorrow I’ll explore:
Building my own Dockerfile
Understanding layers and caching
Creating a custom image from scratch
Running a web server (Nginx or Node.js)
🧠 Final Thoughts
Day 2 gave me confidence with the CLI. Docker is no longer a black box — I’m finally understanding how it pulls, builds, and runs everything.
This is the real DevOps playground, and I’m just getting started.
See you on Day 3. Let’s containerize everything 🚀
🔖 Tags
#Docker #DevOps #LearnInPublic #BuildInPublic #Hashnode #CloudEngineering #Containers
Subscribe to my newsletter
Read articles from Abdul Raheem directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Abdul Raheem
Abdul Raheem
Cloud DevOps | AWS | Terraform | CI/CD | Obsessed with clean infrastructure. Cloud DevOps Engineer 🚀 | Automating Infrastructure & Securing Pipelines | Bridging Gaps Between Code and Cloud ☁️ I’m on a mission to master DevOps from the ground up—building scalable systems, automating workflows, and integrating security into every phase of the SDLC. Currently working with AWS, Terraform, Docker, CI/CD, and learning the art of cloud-native development.