Mastering Docker: A Beginner-Friendly Guide to Containers & Images


Hey readers,today I’m going to go through all the important docker concepts,terminologies and commands to get you up and running with docker,this guide is your complete starting point for learning Docker — the powerful tool that makes app packaging, shipping, and running easier than ever.
In this post, I’ll walk you through everything you need to get started with Docker
💡 If you're still wondering “How are containers different from virtual machines?”, I’ve already written a beginner-friendly guide breaking that down — check it out here: Containers vs VMs: What’s the Difference?
🐳Why Docker? A Quick Context
Imagine being able to package your app along with everything it needs — code, libraries, settings — and run it anywhere. That’s exactly what Docker helps you do. No more “it works on my machine” headaches. With Docker, your app runs the same in development, testing, and production.
Think of Docker containers like lightweight, fast, and portable mini-computers that isolate your app. They're built from images, which are blueprints that define what goes into a container.
Let’s not get too ahead though — before we build our own images, let’s first install Docker and run our first container!
🛠️ Installing Docker (Windows, macOS, Linux)
Here’s how to install Docker on your system:
🔵 For Windows & macOS:
Go to the official Docker Desktop page:
👉 https://www.docker.com/products/docker-desktop/Download the appropriate version for your OS and install it.
Once installed, launch Docker Desktop. You should see the Docker whale 🐳 icon running in your system tray.
Open your terminal (Command Prompt, PowerShell, or macOS Terminal) and verify the installation:
docker --version
You should see something like:
Docker version 25.0.0, build 123456
🟢 For Linux (Ubuntu example):
sudo apt update
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker
docker --version
You might also want to run Docker without sudo
:
sudo usermod -aG docker $USER
# Log out and back in again for the group change to take effect
🚀 Running Your First Docker Command
Let’s now test if Docker is working by running a built-in test container called hello-world.
🔹 Run:
docker run hello-world
If everything is set up correctly, Docker will:
Download the
hello-world
image (if it’s not already present)Run it in a new container
Show this message:
Hello from Docker!
This message shows that your installation appears to be working correctly.
👏 And just like that — you’ve run your first container!
Now let’s discuss docker’s architecture and it’s constitutes.
Docker architecture
Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers,the Docker client and daemon communicate using a REST API and both run on the same machine you cannot connect your docker client to a remote daemon.Another Docker client is Docker Compose, that lets you work with applications consisting of a set of containers,we will come to that later.
🐳 1. Docker Client (docker
command)
📌 What is it?
The Docker Client is what you interact with. It’s the command-line tool (docker
) that you use to tell Docker what to do.
When you type commands like:
docker build
docker run
docker ps
—you’re using the Docker Client.
🧠 How does it work?
The Docker Client sends your commands to the Docker Daemon (which does the real work behind the scenes). Think of the client as the "remote control" or interface.
Example:
You rundocker run nginx
→ The client passes that request to the daemon → The daemon creates the container and starts it.
⚙️ 2. Docker Daemon (dockerd
)
📌 What is it?
The Docker Daemon is the engine that runs in the background. It listens for Docker commands from the client and performs tasks like:
Building images
Running containers
Managing networks and volumes
It’s the brain that makes everything work under the hood.
🧠 How does it work?
The daemon handles all heavy lifting. It communicates with the host OS and creates containers using images.
You rarely interact with the Docker Daemon directly. It’s like the waiter who takes your order (via the Docker Client) and brings your food (containers/images).
☁️ 3. Docker Hub
📌 What is it?
Docker Hub is a cloud-based registry where Docker images are stored and shared. Think of it like GitHub, but for Docker images.
You can:
Pull existing images from Docker Hub (e.g.,
nginx
,mysql
,ubuntu
)Push your own custom images to Docker Hub so others can use them
It's the default registry Docker uses when you type
docker pull
ordocker run
.
🔐 Example:
docker pull python
This downloads the latest official Python image from Docker Hub to your local machine.
Images
An image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization. For example, you may build an image which is based on the ubuntu
image, but installs the Apache web server and your application, as well as the configuration details needed to make your application run.
🧱 Working with Containers
▶️ Run a Container
docker run -it ubuntu /bin/bash
docker run
: Starts a new container.-it
: Enables interactive mode and a pseudo-terminal so you can interact with the container's shell.ubuntu
: Specifies the image to run./bin/bash
: Command to run inside the container (the bash shell).
📦 Run in Detached Mode
-d
or —detach
allows a container to run in the background without being attached to the terminal's input or output streams.
docker run -d nginx
-d
: Runs the container in the background (detached).nginx
: Runs the Nginx web server image.
📋 List Containers
docker ps # Shows only running containers
docker ps -a # Shows all containers (running + stopped)
🛑 Stop and Remove Containers
docker stop <container_id>
docker rm <container_id>
docker stop
: Gracefully stops a running container.
docker rm
: Deletes a stopped container from your system.
🔁 Map Ports Between Host and Container
docker run -d -p 8080:80 nginx
-p 8080:80
: Maps port 80
inside the container (where Nginx runs) to port 8080
on your host machine. Access the app via http://localhost:8080
.
✅ What We’ve Learned So Far
What Docker is and why it matters
How to install Docker
Running your first container with
hello-world
Key components: Docker Client, Docker Daemon & Docker Hub
Some basic Docker commands
🔜 Up Next
In the next tutorial, I’ll show you how to Dockerize a Python app using a Dockerfile
, build your own image, push it to Docker Hub! And as a bonus I will be providing something that will can be helpful for anyone,Stay tuned! 🐳✨
Subscribe to my newsletter
Read articles from Prianshu Mukherjee directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
