π³ All Docker Commands Explained with Examples (2026 Complete Reference)
A complete beginner-friendly Docker CLI guide covering containers, images, volumes, networks, Docker Compose, registries, debugging, Docker Buildx, Swarm, and useful real-world commands.

Docker is one of the most important technologies for modern software development, DevOps, cloud engineering, and CI/CD.
If you are learning DevOps, AWS, Kubernetes, CI/CD, or cloud computing, Docker is one of the tools you should become comfortable with.
But when beginners start learning Docker, one problem appears again and again:
There are so many Docker commands. Which command should I use, and when?
This guide is designed to solve that problem.
Instead of simply giving you a list of commands, we will understand:
What each Docker command does
Why we use it
When we should use it
Command syntax
Real-world examples
Important options
Common mistakes
Beginner tips
Docker Compose commands
Docker networking
Docker volumes
Docker image management
Docker registry commands
Docker Buildx
Docker Swarm
Troubleshooting commands
A final Docker cheat sheet
By the end of this article, you should be able to use the Docker CLI confidently in your development and DevOps projects.
π Table of Contents
π³ What Is Docker?
Docker is a platform used to build, package, distribute, and run applications inside containers.
A container packages an application together with the dependencies it needs to run.
For example, imagine your application requires:
Application
+
Python
+
Required Libraries
+
Environment Variables
+
System Dependencies
Docker allows you to package these requirements into an image and run that image as a container.
A simple way to remember the relationship is:
Dockerfile
β
Docker Image
β
Docker Container
Dockerfile
A Dockerfile contains instructions for creating an image.
Docker Image
An image is a reusable package/template containing the application and its required environment.
Docker Container
A container is a running instance of an image.
ποΈ Docker Architecture in Simple Words
A simplified Docker architecture looks like this:
Docker CLI
|
β
Docker Engine
|
---------------------
| | |
Images Containers Networks
|
Volumes
When you run:
docker run nginx
Docker approximately performs this flow:
Docker CLI
β
Check local image
β
Image not available?
β
Pull image from registry
β
Create container
β
Start container
The Docker documentation describes docker run as creating and running a new container from an image; if the image is unavailable locally, Docker can pull it first.
π» Docker Command Syntax
Most Docker commands follow this pattern:
docker <command> <options> <arguments>
For example:
docker run -d -p 8080:80 nginx
Here:
docker β Docker CLI
run β command
-d β run in detached mode
-p β publish a port
8080:80 β host:container port
nginx β image
You can get help for almost any Docker command using:
docker --help
Or:
docker run --help
Docker officially supports the --help option for displaying command-specific help.
1οΈβ£ Check Docker Installation
Before learning Docker commands, verify that Docker is installed.
Check Docker Version
docker --version
Example:
Docker version 28.x.x, build xxxxx
This tells you the installed Docker CLI version.
Detailed Docker Version
docker version
This can show information about both the Docker client and server/engine.
Use it when troubleshooting version compatibility.
Docker System Information
docker info
This provides information about the Docker environment.
It can include:
Containers
Images
Storage driver
Docker root directory
CPUs
Memory
Plugins
Server information
Useful when troubleshooting Docker.
Docker Help
docker --help
For a specific command:
docker run --help
2οΈβ£ Docker Container Commands
Containers are where your applications actually run.
Let's learn the most important container commands.
docker run
The most important Docker command for beginners.
docker run nginx
It creates and starts a new container from the nginx image.
If the image isn't available locally, Docker can pull it from a registry.
Run in Background
docker run -d nginx
-d means:
Detached mode
The container runs in the background.
Give the Container a Name
docker run --name my-nginx -d nginx
Now instead of using a random container name, you can use:
docker stop my-nginx
Docker supports custom container names through the --name option.
Map a Port
docker run -d -p 8080:80 nginx
The format is:
-p HOST_PORT:CONTAINER_PORT
So:
8080 β Your computer
80 β Container
You can then access:
http://localhost:8080
Run an Interactive Ubuntu Container
docker run -it ubuntu /bin/bash
Meaning:
-i β interactive
-t β terminal
Now you can work inside the Ubuntu container.
Run a Specific Image Version
docker run nginx:1.27
Here:
nginx β image
1.27 β tag
Avoid blindly relying on latest in production deployments when reproducibility matters.
docker create
Creates a container but does not start it.
docker create --name mycontainer nginx
Then start it:
docker start mycontainer
Think:
docker create β Create
docker start β Start
While:
docker run β Create + Start
docker start
Starts an existing stopped container.
docker start mycontainer
Important:
docker run
creates a new container.
docker start
starts an existing container.
docker stop
Stops a running container gracefully.
docker stop mycontainer
Example:
docker stop nginx-container
Use this when you want to shut down an application cleanly.
docker restart
Restarts a container.
docker restart mycontainer
Useful when a service needs to be restarted after a configuration change or temporary problem.
docker pause
Pauses all processes inside a container.
docker pause mycontainer
docker unpause
Resumes a paused container.
docker unpause mycontainer
docker kill
Forcefully stops a running container.
docker kill mycontainer
Use docker stop for normal shutdowns.
Use docker kill when the container is stuck or doesn't respond properly.
docker rm
Removes a container.
docker rm mycontainer
If the container is still running, Docker normally requires you to stop it first.
You can force removal:
docker rm -f mycontainer
β οΈ Be careful with -f.
docker rename
Renames a container.
docker rename old-name new-name
Example:
docker rename nginx-container web-server
docker wait
Waits until a container stops and then prints its exit code.
docker wait mycontainer
Useful in automation and scripts.
docker container prune
Removes all stopped containers.
docker container prune
Docker asks for confirmation before deleting them.
3οΈβ£ Docker Image Commands
An image is a package/template used to create containers.
Think:
Image
β
Container
One image can be used to create many containers.
docker pull
Downloads an image from a registry.
docker pull nginx
Specific version:
docker pull nginx:1.27
Ubuntu:
docker pull ubuntu:24.04
docker images
Lists locally available images.
docker images
Example output:
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest abc123 2 days ago 190MB
ubuntu 24.04 xyz456 3 days ago 78MB
docker image ls
Modern object-oriented form of listing images:
docker image ls
It is equivalent to:
docker images
docker build
Builds an image from a Dockerfile.
Suppose your project contains:
myapp/
βββ Dockerfile
βββ app.py
Build the image:
docker build -t myapp:1.0 .
Meaning:
-t myapp:1.0 β image name and tag
. β current directory
Example Dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY app.py .
CMD ["python", "app.py"]
Build:
docker build -t python-app:1.0 .
Run:
docker run python-app:1.0
docker rmi
Removes an image.
docker rmi nginx
Or:
docker rmi nginx:latest
Force removal:
docker rmi -f nginx
Be careful because removing an image can affect containers that depend on it.
docker image rm
Equivalent object-oriented form:
docker image rm nginx
docker tag
Creates another tag/reference for an image.
docker tag myapp:latest username/myapp:v1
This is commonly used before pushing an image to Docker Hub or another registry.
docker history
Shows the layers used to create an image.
docker history nginx
This can help you understand image construction and investigate image size.
docker inspect
Displays detailed information about Docker objects.
For an image:
docker image inspect nginx
For a container:
docker inspect mycontainer
The output is usually JSON.
It can contain information such as:
Environment variables
Network configuration
Mounts
IP addresses
Image configuration
Container state
docker save
Saves an image to a tar archive.
docker save -o myimage.tar myapp:latest
Useful when you need to transfer an image without directly pulling it from a registry.
docker load
Loads an image from a tar archive.
docker load -i myimage.tar
Typical workflow:
Machine A
β
docker save
β
myimage.tar
β
Transfer file
β
Machine B
β
docker load
4οΈβ£ Docker Registry Commands
A registry stores Docker images.
Examples include:
Docker Hub
Amazon ECR
GitHub Container Registry
Google Artifact Registry
Azure Container Registry
Private registries
docker login
Log in to a container registry.
docker login
For a specific registry:
docker login registry.example.com
docker logout
Log out from a registry.
docker logout
docker search
Search Docker Hub for images.
docker search nginx
You can use it to discover available images.
Always verify image ownership and trust before using third-party images.
docker push
Push an image to a registry.
First tag your image:
docker tag myapp:latest username/myapp:latest
Then:
docker push username/myapp:latest
Typical workflow:
Build
β
Tag
β
Login
β
Push
β
Registry
5οΈβ£ Docker Logs and Debugging
Debugging is one of the most important Docker skills.
docker ps
Shows running containers.
docker ps
docker ps -a
Shows all containers, including stopped containers.
docker ps -a
This is one of the first commands you should use when a container isn't behaving as expected.
docker logs
View container logs.
docker logs mycontainer
Follow Logs
docker logs -f mycontainer
-f means follow.
It behaves similarly to:
tail -f
Show Last 100 Lines
docker logs --tail 100 mycontainer
Show Logs with Timestamps
docker logs -t mycontainer
docker top
Shows processes running inside a container.
docker top mycontainer
Useful for checking whether the expected application process is running.
docker stats
Displays live resource usage.
docker stats
It can show:
CPU %
Memory Usage
Memory %
Network I/O
Block I/O
PIDs
For a specific container:
docker stats mycontainer
docker port
Shows port mappings.
docker port mycontainer
Example:
80/tcp -> 0.0.0.0:8080
This means container port 80 is exposed through host port 8080.
docker diff
Shows filesystem changes made inside a container.
docker diff mycontainer
Useful when troubleshooting unexpected file changes.
docker events
Shows real-time Docker events.
docker events
You may see events such as:
container create
container start
container stop
network connect
image pull
Useful for troubleshooting and automation.
docker inspect
One of the most powerful debugging commands.
docker inspect mycontainer
For example, to find the container IP:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mycontainer
docker system df
Shows Docker disk usage.
docker system df
This helps identify whether images, containers, volumes, or build cache are consuming disk space.
6οΈβ£ Docker Volume Commands
Containers are designed to be replaceable.
But application data often needs to survive container deletion.
This is where volumes are useful.
Container
|
β
Volume
|
β
Persistent Data
docker volume create
Create a volume:
docker volume create my_volume
docker volume ls
List volumes:
docker volume ls
docker volume inspect
Inspect a volume:
docker volume inspect my_volume
Use a Volume with a Container
docker run -d \
--name mysql \
-v mysql_data:/var/lib/mysql \
mysql
Here:
mysql_data β Docker volume
/var/lib/mysql β Path inside container
If the container is removed, the named volume can remain.
docker volume rm
Remove a volume:
docker volume rm my_volume
β οΈ Removing a volume can permanently delete stored data.
docker volume prune
Remove unused volumes:
docker volume prune
Use this carefully.
7οΈβ£ Docker Network Commands
Containers often need to communicate with:
Other containers
The host
External services
Databases
APIs
Docker networking makes this possible.
docker network ls
List networks:
docker network ls
Typical default networks include:
bridge
host
none
docker network create
Create a custom network:
docker network create my_network
Run Container on a Network
docker run -d \
--name web \
--network my_network \
nginx
docker network inspect
Inspect a network:
docker network inspect my_network
This can show connected containers and network configuration.
docker network connect
Connect an existing container to a network:
docker network connect my_network mycontainer
docker network disconnect
Disconnect:
docker network disconnect my_network mycontainer
docker network rm
Remove a network:
docker network rm my_network
docker network prune
Remove unused networks:
docker network prune
π§ Container-to-Container Communication Example
Create a network:
docker network create app-network
Run Redis:
docker run -d \
--name redis \
--network app-network \
redis
Run another container:
docker run -it \
--network app-network \
busybox
Inside the second container, redis can be used as the hostname because Docker's user-defined networks provide service/container name-based communication.
8οΈβ£ Interact With a Running Container
Sometimes you need to enter a container to troubleshoot it.
The most useful command is:
docker exec
docker exec
Run a command inside a running container.
docker exec mycontainer ls
Open a Bash Shell
docker exec -it mycontainer /bin/bash
If Bash isn't available:
docker exec -it mycontainer /bin/sh
Important:
-i β interactive
-t β terminal
Docker documents docker exec as executing a new command inside a running container.
Run One Command
docker exec mycontainer ls /app
Run as Root
docker exec -u root -it mycontainer sh
Set Working Directory
docker exec -w /app mycontainer pwd
docker attach
Attaches your terminal to a container's main process.
docker attach mycontainer
This is different from docker exec.
docker exec
Starts a new process inside the container.
docker attach
Connects to the container's existing main process.
For beginners, docker exec is generally the safer choice for interactive troubleshooting.
9οΈβ£ Copy Files Between Host and Container
docker cp
Copy a file from host to container:
docker cp app.conf mycontainer:/app/app.conf
Copy a file from container to host:
docker cp mycontainer:/app/log.txt ./log.txt
Copy a directory:
docker cp ./config mycontainer:/app/
Useful for:
Debugging
Retrieving logs
Moving configuration
Temporary file transfers
For production applications, prefer proper image builds, volumes, or configuration mechanisms instead of manually modifying running containers.
π Docker Cleanup Commands
Docker can consume significant disk space.
Images, containers, volumes, networks, and build cache can accumulate over time.
docker container prune
Remove stopped containers:
docker container prune
docker image prune
Remove dangling images:
docker image prune
docker image prune -a
Remove unused images more aggressively:
docker image prune -a
Be careful because images you may want later can be removed.
docker network prune
Remove unused networks:
docker network prune
docker volume prune
Remove unused volumes:
docker volume prune
β οΈ Volumes may contain important application or database data.
docker system prune
Clean unused Docker resources:
docker system prune
docker system prune -a
More aggressive cleanup:
docker system prune -a
This can remove unused images in addition to stopped containers and unused networks.
Always review what you're deleting before running cleanup commands on important systems.
docker system df
Before cleaning, check usage:
docker system df
A good habit is:
Check
β
docker system df
β
Clean
β
docker system prune
1οΈβ£1οΈβ£ Docker Commit, Export and Import
These commands are less common in modern application workflows but are useful to understand.
docker commit
Creates a new image from a container's changes.
docker commit mycontainer myimage:v1
For example:
Running Container
β
Manual Changes
β
docker commit
β
New Image
However, for reproducible application builds, a Dockerfile is usually preferred.
docker export
Exports a container filesystem as a tar archive.
docker export mycontainer > backup.tar
Important distinction:
docker export exports a container filesystem.
It does not preserve the image's complete layer history.
docker import
Creates an image from a tar archive.
docker import backup.tar restored-image:latest
docker save vs docker export
This is a common interview question.
docker save
Used for images.
docker save -o image.tar myimage
docker export
Used for containers.
docker export mycontainer > container.tar
Remember:
IMAGE β docker save
CONTAINER β docker export
1οΈβ£2οΈβ£ Docker Compose Commands
Docker Compose is used to define and run multi-container applications.
For example:
Application
|
+--- Frontend
|
+--- Backend
|
+--- Database
|
+--- Redis
Instead of manually running every container, Compose allows you to define the application stack in a YAML file.
Docker's current documentation describes Compose as a tool for defining and running multi-container applications.
Modern Docker uses:
docker compose
rather than the older standalone:
docker-compose
docker compose up
Start the application stack:
docker compose up
Run in background:
docker compose up -d
docker compose down
Stop and remove Compose-managed containers and networks:
docker compose down
docker compose build
Build service images:
docker compose build
docker compose up --build
Build images and start services:
docker compose up --build
docker compose ps
Show Compose containers:
docker compose ps
Include stopped containers:
docker compose ps --all
The current Compose CLI supports --all to include stopped containers.
docker compose logs
Show logs:
docker compose logs
Follow logs:
docker compose logs -f
Specific service:
docker compose logs -f backend
docker compose exec
Run a command inside a service container:
docker compose exec web sh
For example:
docker compose exec db sh
Compose provides service-oriented execution, so you don't need to remember the generated container name.
docker compose pull
Pull service images:
docker compose pull
docker compose push
Push service images:
docker compose push
docker compose start
Start existing containers:
docker compose start
Important difference:
docker compose up
creates and starts containers when necessary.
docker compose start
starts existing containers.
Docker documents compose start specifically as starting existing service containers.
docker compose stop
Stop services:
docker compose stop
The containers remain available to start again.
docker compose restart
Restart services:
docker compose restart
docker compose rm
Remove stopped service containers:
docker compose rm
docker compose run
Run a one-time command for a service:
docker compose run web sh
Useful for:
Database migrations
Admin commands
One-time scripts
Debugging
docker compose config
Validate and render the Compose configuration:
docker compose config
This is very useful when debugging YAML, environment variables, or merged Compose files.
docker compose images
List images used by the Compose project:
docker compose images
docker compose top
Show processes running inside service containers:
docker compose top
docker compose stats
Show resource usage:
docker compose stats
docker compose port
Show the public port mapping for a service:
docker compose port web 80
docker compose ls
List Compose projects:
docker compose ls
docker compose --dry-run
Modern Docker Compose also supports dry-run mode for testing commands without applying stack changes.
Example:
docker compose --dry-run up --build -d
This is particularly useful when you want to understand what Compose plans to do before actually changing the environment.
1οΈβ£3οΈβ£ Real-World Docker Compose Example
Let's create a simple application with:
Web
Database
Create:
compose.yaml
Example:
services:
web:
image: nginx:alpine
ports:
- "8080:80"
redis:
image: redis:alpine
Start:
docker compose up -d
Check:
docker compose ps
View logs:
docker compose logs
Stop:
docker compose stop
Start again:
docker compose start
Remove the stack:
docker compose down
The current Compose Specification is the recommended Compose file format; older Compose 2.x and 3.x file formats were merged into the Compose Specification.
1οΈβ£4οΈβ£ Docker Context Commands
Docker contexts allow the CLI to work with different Docker endpoints.
For example:
Local Docker
+
Remote Docker Server
+
Cloud Environment
docker context ls
List contexts:
docker context ls
docker context show
Show the current context:
docker context show
docker context use
Switch context:
docker context use my-context
docker context create
Create a context.
For example, an SSH-based context:
docker context create remote-server --docker "host=ssh://user@server"
Then:
docker context use remote-server
Now Docker commands can target that context.
Switch back:
docker context use default
docker context inspect
Inspect a context:
docker context inspect remote-server
docker context rm
Remove a context:
docker context rm remote-server
1οΈβ£5οΈβ£ Docker Buildx Commands
Buildx provides advanced Docker image building capabilities.
It is especially useful for:
Multi-platform images
Advanced build workflows
CI/CD
Build cache
Modern Docker builds
docker buildx ls
List builders:
docker buildx ls
docker buildx create
Create a builder:
docker buildx create --name mybuilder
Use it:
docker buildx use mybuilder
docker buildx inspect
Inspect a builder:
docker buildx inspect mybuilder
docker buildx build
Build an image:
docker buildx build -t myapp:latest .
Multi-Architecture Build
Build for AMD64 and ARM64:
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t username/myapp:latest \
--push .
This is useful when your application needs to run on different CPU architectures.
For example:
Intel/AMD servers
+
ARM servers
β
Same Docker image tag
1οΈβ£6οΈβ£ Docker Manifest Commands
Manifests help work with image manifests and multi-platform image references.
docker manifest inspect
Inspect a manifest:
docker manifest inspect nginx:latest
This can show information about supported platforms.
docker manifest create
Create a manifest list:
docker manifest create \
myapp:latest \
myapp:amd64 \
myapp:arm64
docker manifest push
Push a manifest list:
docker manifest push myapp:latest
For most modern multi-platform build workflows, Buildx is generally the simpler approach.
1οΈβ£7οΈβ£ Docker Swarm Commands
Docker Swarm is Docker's native clustering/orchestration technology.
Kubernetes is more commonly encountered in modern cloud-native environments, but understanding Swarm is useful for Docker knowledge and interviews.
docker swarm init
Initialize a Swarm:
docker swarm init
If you need to specify the advertised address:
docker swarm init --advertise-addr 192.168.1.10
docker swarm join
Workers can join using the command generated by the manager:
docker swarm join --token <TOKEN> <MANAGER-IP>:2377
docker node ls
List nodes:
docker node ls
docker node inspect
Inspect a node:
docker node inspect node-name
docker node ps
Show tasks running on a node:
docker node ps node-name
docker service create
Create a service:
docker service create \
--name web \
--replicas 3 \
nginx
This creates a service with three replicas.
docker service ls
List services:
docker service ls
docker service ps
Show service tasks:
docker service ps web
docker service scale
Scale a service:
docker service scale web=5
Now:
web
β
5 replicas
docker service update
Update a service:
docker service update --image nginx:latest web
docker service rm
Remove a service:
docker service rm web
docker stack deploy
Deploy a stack using a Compose file:
docker stack deploy -c compose.yaml myapp
docker stack ls
List stacks:
docker stack ls
docker stack services
List services in a stack:
docker stack services myapp
docker stack ps
Show tasks in a stack:
docker stack ps myapp
docker stack rm
Remove a stack:
docker stack rm myapp
1οΈβ£8οΈβ£ Docker Plugin Commands
Docker plugins can extend Docker functionality.
docker plugin ls
List plugins:
docker plugin ls
docker plugin install
Install a plugin:
docker plugin install <plugin>
Only install plugins from sources you trust and understand.
docker plugin enable
Enable a plugin:
docker plugin enable <plugin>
docker plugin disable
Disable:
docker plugin disable <plugin>
docker plugin inspect
Inspect:
docker plugin inspect <plugin>
docker plugin rm
Remove:
docker plugin rm <plugin>
1οΈβ£9οΈβ£ Useful Docker Filters
Docker provides filtering options for many commands.
Find Containers by Status
docker ps -a --filter status=exited
Find Containers by Name
docker ps --filter name=web
Find Containers by Ancestor Image
docker ps --filter ancestor=nginx
Show Only Container IDs
docker ps -q
This is extremely useful in shell scripts.
Example:
docker stop $(docker ps -q)
2οΈβ£0οΈβ£ Useful Docker Formatting Commands
Docker supports output formatting using Go templates.
For example:
docker ps --format "{{.Names}}"
Show container names and status:
docker ps --format "table {{.Names}}\t{{.Status}}"
Show image names:
docker images --format "{{.Repository}}:{{.Tag}}"
This is useful in:
Shell scripting
Automation
CI/CD pipelines
Monitoring scripts
2οΈβ£1οΈβ£ Common Docker Errors
Let's look at some problems beginners frequently face.
β Error: Docker Daemon Is Not Running
You may see an error similar to:
Cannot connect to the Docker daemon
First check:
docker info
On Linux with systemd:
sudo systemctl status docker
Start Docker:
sudo systemctl start docker
Enable Docker at boot:
sudo systemctl enable docker
β Error: Container Name Already in Use
Example:
Conflict. The container name is already in use.
Check:
docker ps -a
Then remove the old container:
docker rm old-container
Or choose another name:
docker run --name new-container nginx
β Error: Port Already Allocated
Example:
port is already allocated
Find containers using ports:
docker ps
You can choose another host port:
docker run -d -p 8081:80 nginx
Now:
localhost:8081
β
container:80
β Container Immediately Exits
Run:
docker ps -a
Then:
docker logs <container>
For example:
docker logs myapp
Check the exit code:
docker inspect myapp
A common reason is that the container's main process finished or crashed.
Remember:
A Docker container stays running only while its primary process is running.
β Cannot Enter Container With Bash
You may try:
docker exec -it mycontainer bash
and receive:
bash: executable file not found
Some lightweight images don't include Bash.
Try:
docker exec -it mycontainer sh
β Image Not Found
Example:
Unable to find image
Try:
docker pull image-name
Check the image name and tag:
docker search image-name
β Permission Denied on Linux
You may need:
sudo docker ps
If your Docker setup allows non-root access through the Docker group, configure it according to your system's Docker installation instructions.
Avoid blindly changing permissions on the Docker socket.
2οΈβ£2οΈβ£ Docker Commands Beginners Should Memorize
You don't need to memorize every Docker command.
Start with these:
docker --version
docker version
docker info
docker pull nginx
docker images
docker run nginx
docker run -d -p 8080:80 nginx
docker ps
docker ps -a
docker stop <container>
docker start <container>
docker restart <container>
docker rm <container>
docker logs <container>
docker exec -it <container> sh
docker inspect <container>
docker stats
docker build -t myapp:latest .
docker rmi <image>
docker login
docker tag <image> <username>/<image>:latest
docker push <username>/<image>:latest
docker volume ls
docker volume create <volume>
docker network ls
docker network create <network>
docker compose up -d
docker compose down
docker compose ps
docker compose logs -f
docker compose exec <service> sh
If you understand these commands, you already have a strong foundation.
2οΈβ£3οΈβ£ Docker Cheat Sheet
π΅ Docker Basics
| Command | Purpose |
|---|---|
docker --version |
Check Docker version |
docker version |
Show client/server version |
docker info |
Show Docker system information |
docker --help |
Show help |
π’ Containers
| Command | Purpose |
|---|---|
docker run |
Create and start container |
docker create |
Create container |
docker start |
Start stopped container |
docker stop |
Stop container |
docker restart |
Restart container |
docker pause |
Pause container |
docker unpause |
Resume container |
docker kill |
Force stop container |
docker rm |
Remove container |
docker rename |
Rename container |
docker ps |
List running containers |
docker ps -a |
List all containers |
docker exec |
Execute command inside container |
docker attach |
Attach to main process |
docker logs |
View logs |
docker stats |
Resource usage |
docker top |
Running processes |
docker inspect |
Detailed information |
docker port |
Show port mappings |
docker diff |
Show filesystem changes |
π‘ Images
| Command | Purpose |
|---|---|
docker pull |
Download image |
docker build |
Build image |
docker images |
List images |
docker image ls |
List images |
docker rmi |
Remove image |
docker tag |
Create image tag |
docker history |
Show image layers |
docker save |
Save image to tar |
docker load |
Load image from tar |
docker inspect |
Inspect image/object |
π£ Volumes
| Command | Purpose |
|---|---|
docker volume create |
Create volume |
docker volume ls |
List volumes |
docker volume inspect |
Inspect volume |
docker volume rm |
Remove volume |
docker volume prune |
Remove unused volumes |
π΄ Networks
| Command | Purpose |
|---|---|
docker network create |
Create network |
docker network ls |
List networks |
docker network inspect |
Inspect network |
docker network connect |
Connect container |
docker network disconnect |
Disconnect container |
docker network rm |
Remove network |
docker network prune |
Remove unused networks |
π Registry
| Command | Purpose |
|---|---|
docker login |
Login to registry |
docker logout |
Logout |
docker search |
Search Docker Hub |
docker tag |
Tag image |
docker push |
Push image |
docker pull |
Pull image |
π€ Compose
| Command | Purpose |
|---|---|
docker compose up |
Create/start services |
docker compose down |
Stop/remove stack |
docker compose build |
Build services |
docker compose ps |
List services |
docker compose logs |
View logs |
docker compose exec |
Execute command |
docker compose pull |
Pull images |
docker compose push |
Push images |
docker compose start |
Start existing services |
docker compose stop |
Stop services |
docker compose restart |
Restart services |
docker compose run |
Run one-off command |
docker compose config |
Validate/render config |
π§ Most Important Docker Concepts to Understand
Don't just memorize commands.
Understand these relationships:
Dockerfile
β
docker build
β
Docker Image
β
docker run
β
Docker Container
β
docker stop
β
Stopped Container
β
docker start
β
Running Container
For persistent storage:
Container
β
Volume
β
Persistent Data
For networking:
Container A
β
Docker Network
β
Container B
For image distribution:
Dockerfile
β
Build Image
β
Tag Image
β
Docker Registry
β
Push Image
β
Pull Image
β
Run Container
π Real-World Docker Workflow
A common application workflow looks like this:
Step 1: Create Dockerfile
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
Step 2: Build Image
docker build -t my-node-app:1.0 .
Step 3: Run Container
docker run -d \
--name my-node-app \
-p 3000:3000 \
my-node-app:1.0
Step 4: Check Container
docker ps
Step 5: Check Logs
docker logs my-node-app
Step 6: Enter Container
docker exec -it my-node-app sh
Step 7: Stop Application
docker stop my-node-app
Step 8: Remove Container
docker rm my-node-app
π Docker CI/CD Workflow
Docker is heavily used in CI/CD pipelines.
A simplified workflow looks like:
Developer
β
Git Push
β
CI Pipeline
β
Run Tests
β
docker build
β
Docker Image
β
docker tag
β
docker push
β
Container Registry
β
Deployment Server
β
docker pull
β
docker run
For example:
docker build -t myapp:1.0 .
Then:
docker tag myapp:1.0 username/myapp:1.0
Then:
docker push username/myapp:1.0
On the deployment server:
docker pull username/myapp:1.0
Then:
docker run -d username/myapp:1.0
This is one of the fundamental Docker workflows used in DevOps.
π― Docker Interview Questions Based on These Commands
If you're preparing for a DevOps interview, make sure you can answer these.
1. What is the difference between docker run and docker start?
docker run
= Create + Start a new container
docker start
= Start an existing stopped container
2. What is the difference between docker stop and docker kill?
docker stop
= Graceful shutdown
docker kill
= Forceful shutdown
3. What is the difference between an image and a container?
Image
= Template/package
Container
= Running instance of an image
4. What is the difference between docker exec and docker attach?
docker exec
= Starts a new process
docker attach
= Connects to the existing main process
5. What is the difference between docker save and docker export?
docker save
= Save an image
docker export
= Export a container filesystem
6. What is the difference between docker compose up and docker compose start?
docker compose up
= Creates/recreates and starts services when needed
docker compose start
= Starts existing service containers
7. How do you check container logs?
docker logs <container>
8. How do you enter a running container?
docker exec -it <container> sh
or:
docker exec -it <container> bash
depending on the image.
9. How do you check Docker disk usage?
docker system df
10. How do you remove unused Docker resources?
docker system prune
β οΈ Important Docker Safety Tips
Docker commands can delete data, so be careful.
Especially review these commands before running them:
docker rm -f
docker rmi -f
docker volume rm
docker volume prune
docker system prune
docker system prune -a
The most dangerous mistake for beginners is deleting a volume containing important database data.
Before cleanup, inspect:
docker volume ls
and:
docker system df
π§© Docker Command Mental Model
If you forget a command, think about what you are trying to manage.
What am I managing?
|
+---- Container?
| |
| +-- docker ps
| +-- docker run
| +-- docker stop
| +-- docker exec
| +-- docker logs
|
+---- Image?
| |
| +-- docker pull
| +-- docker build
| +-- docker images
| +-- docker push
|
+---- Volume?
| |
| +-- docker volume ls
| +-- docker volume create
| +-- docker volume inspect
|
+---- Network?
| |
| +-- docker network ls
| +-- docker network create
| +-- docker network inspect
|
+---- Multi-container app?
| |
| +-- docker compose up
| +-- docker compose down
| +-- docker compose logs
|
+---- Build?
|
+-- docker build
+-- docker buildx build
This mental model is much more useful than trying to memorize hundreds of commands.
π Docker Learning Roadmap
If you are completely new to Docker, don't try to learn everything in one day.
Follow this order:
1. Docker Basics
β
2. Images
β
3. Containers
β
4. Dockerfile
β
5. Ports
β
6. Volumes
β
7. Networks
β
8. Docker Compose
β
9. Docker Registry
β
10. Docker Buildx
β
11. CI/CD
β
12. Kubernetes
π Docker Commands You Should Know for DevOps
If your goal is to become a DevOps Engineer, prioritize these:
docker pull
docker build
docker run
docker ps
docker ps -a
docker stop
docker start
docker restart
docker rm
docker exec
docker logs
docker inspect
docker stats
docker images
docker rmi
docker tag
docker push
docker login
docker volume ls
docker volume create
docker volume inspect
docker network ls
docker network create
docker network inspect
docker network connect
docker compose up
docker compose down
docker compose ps
docker compose logs
docker compose exec
docker compose build
docker system df
docker system prune
docker buildx build
docker buildx ls
π‘ Final Advice for Beginners
The biggest mistake beginners make is trying to memorize Docker commands.
Don't do that.
Instead, understand the lifecycle:
Build
β
Image
β
Run
β
Container
β
Inspect
β
Logs
β
Debug
β
Stop
β
Remove
Then understand supporting resources:
Container
βββ Network
βββ Volume
βββ Image
And for multi-container applications:
Docker Compose
β
Multiple Containers
β
Networks + Volumes
β
Complete Application
Once you understand this flow, Docker commands become much easier.
π Quick Docker Practice Lab
If you are a beginner, try these commands yourself.
Step 1 β Pull Nginx
docker pull nginx
Step 2 β Run Nginx
docker run -d --name my-nginx -p 8080:80 nginx
Step 3 β Check Container
docker ps
Step 4 β Open in Browser
http://localhost:8080
Step 5 β Check Logs
docker logs my-nginx
Step 6 β Inspect
docker inspect my-nginx
Step 7 β Enter Container
docker exec -it my-nginx sh
Step 8 β Check Processes
docker top my-nginx
Step 9 β Check Resources
docker stats my-nginx
Step 10 β Stop Container
docker stop my-nginx
Step 11 β Start Again
docker start my-nginx
Step 12 β Remove Container
docker stop my-nginx
docker rm my-nginx
Congratulations π
You have just completed a basic Docker container lifecycle.
π₯ Final Docker Cheat Sheet
# Docker
docker --version
docker version
docker info
docker --help
# Images
docker pull nginx
docker images
docker build -t myapp .
docker rmi myapp
docker tag myapp username/myapp:v1
docker push username/myapp:v1
docker history nginx
docker save -o image.tar myapp
docker load -i image.tar
# Containers
docker run -d nginx
docker run --name web -d -p 8080:80 nginx
docker ps
docker ps -a
docker create nginx
docker start web
docker stop web
docker restart web
docker pause web
docker unpause web
docker kill web
docker rm web
docker rename web web-server
# Debugging
docker logs web
docker logs -f web
docker inspect web
docker exec -it web sh
docker top web
docker stats web
docker port web
docker diff web
docker events
# Files
docker cp file.txt web:/tmp/
docker cp web:/tmp/file.txt .
# Volumes
docker volume create data
docker volume ls
docker volume inspect data
docker volume rm data
docker volume prune
# Networks
docker network create app-network
docker network ls
docker network inspect app-network
docker network connect app-network web
docker network disconnect app-network web
docker network rm app-network
docker network prune
# Cleanup
docker system df
docker container prune
docker image prune
docker network prune
docker volume prune
docker system prune
docker system prune -a
# Registry
docker login
docker logout
docker search nginx
docker tag myapp username/myapp:latest
docker push username/myapp:latest
# Compose
docker compose up -d
docker compose down
docker compose build
docker compose up --build -d
docker compose ps
docker compose logs -f
docker compose exec web sh
docker compose pull
docker compose push
docker compose start
docker compose stop
docker compose restart
docker compose run web sh
docker compose config
docker compose ls
# Context
docker context ls
docker context show
docker context inspect
docker context create
docker context use
docker context rm
# Buildx
docker buildx ls
docker buildx create --name builder
docker buildx use builder
docker buildx inspect builder
docker buildx build -t myapp .
# Swarm
docker swarm init
docker node ls
docker service create
docker service ls
docker service ps
docker service scale
docker service update
docker service rm
docker stack deploy
docker stack ls
docker stack services
docker stack ps
docker stack rm
π― Conclusion
Docker becomes much easier when you stop treating it as a collection of commands and start understanding the relationship between its components.
Remember this:
Dockerfile
β
docker build
β
Image
β
docker run
β
Container
β
docker exec / logs / inspect
β
Debug & Manage
β
docker stop
β
docker rm
For persistent data:
Volume
For communication:
Network
For multiple containers:
Docker Compose
For sharing images:
Docker Registry
For multi-platform builds:
Docker Buildx
For container orchestration with Docker:
Docker Swarm
The official Docker CLI reference provides the current command hierarchy and includes areas such as containers, images, Compose, contexts, Buildx, manifests, and newer CLI capabilities.
The best way to learn Docker is simple:
Don't just read Docker commands. Run them. Break things. Inspect them. Fix them. Repeat.
Start with:
docker run
docker ps
docker logs
docker exec
docker inspect
docker stop
docker rm
Then move to:
docker build
docker volume
docker network
docker compose
docker push
docker buildx
With regular practice, Docker will stop feeling like a huge list of commands and start feeling like a logical workflow.
π What's Next?
If you're learning DevOps, your next topics after Docker should be:
Docker
β
Docker Compose
β
Docker Registry
β
Jenkins / GitHub Actions
β
CI/CD
β
AWS
β
Kubernetes
β
Helm
β
Monitoring
β
Prometheus + Grafana
Keep practicing, keep building, and keep shipping. ππ³
Happy Dockering!
π Complete Learning & Career Resources | 2027β2028
A curated collection of learning resources for AI, Data Analytics, Python, Data Engineering, Cybersecurity, Cloud, Networking, Finance, Digital Marketing, Project Management, DevOps and Generative AI.
π Learn Β βΒ π§ͺ Practice Β βΒ π οΈ Build Β βΒ π Share Β βΒ π Grow
π About This Repository
Welcome to the Complete Learning & Career Resources Repository! π
This repository is designed as a centralized learning hub for students, developers, QA engineers, DevOps engineers, cloud learners, cybersecurity enthusiasts, data professionals, project managers, business professionals and anyone interested in continuous learning.
The goal is simple:
Learn β Practice β Build β Document β Share β Grow
Instead of searching for useful resources again and again, this repository brings them together in one place.
π― What You Will Find Here
π€ Artificial Intelligence
π§ Generative AI
π Data Analytics
π Python
βοΈ Data Engineering
βοΈ Cloud Computing
π Computer Networking
π Cybersecurity
βοΈ DevOps
π Project Management
π° Finance
π Digital Marketing
π§© Business Analysis
π Career Development
π Professional Learning
π οΈ Project Ideas
π Learning Roadmaps
π Repository Overview
| Category | Resources |
|---|---|
| π€ AI Courses | 15 |
| π΅ Google Courses | 15 |
| π£ IBM Courses | 10 |
| π₯ Best Courses 2027β2028 | 21 |
| π Learning & Career Resources | 14 |
| π Personal Resources | 4+ |
π Table of Contents
π€ AI Courses
π Explore AI fundamentals, Python, AI infrastructure, Generative AI, AI governance and specialized AI applications.
| # | Course | Link |
|---|---|---|
| 1 | AI For Everyone | Start Course β |
| 2 | AI Python for Beginners | Start Course β |
| 3 | AI Infrastructure and Operations Fundamentals | Start Course β |
| 4 | Generative AI for Human Resources (HR) Professionals | Start Course β |
| 5 | AI Fundamentals | Start Course β |
| 6 | AI for Healthcare | Start Course β |
| 7 | AI Applications in Accounting and Finance | Start Course β |
| 8 | AI Governance and Privacy Professional Certification (AIGP) | Start Course β |
| 9 | Ethics and Governance in the Age of Generative AI | Start Course β |
| 10 | Hands-on quantum error correction with Google Quantum AI | Start Course β |
| 11 | AI-Powered Higher Education | Start Course β |
| 12 | Modern Project Leadership: Agile, AI, and Beyond | Start Course β |
| 13 | AI-Powered Business Analysis: Excel, KPIs & GenAI | Start Course β |
| 14 | AI in Law: Research, Risk, and Legal Drafting | Start Course β |
| 15 | Generative AI for Project Managers | Start Course β |
π΅ Google Courses
π Explore Data Analytics, AI, Cybersecurity, Networking, Cloud, Digital Marketing and Project Management.
| # | Course | Link |
|---|---|---|
| 1 | Foundations: Data, Data, Everywhere | Start Course β |
| 2 | Ask Questions to Make Data-Driven Decisions | Start Course β |
| 3 | Prepare Data for Exploration | Start Course β |
| 4 | Agile Project Management | Start Course β |
| 5 | Project Initiation: Starting a Successful Project | Start Course β |
| 6 | AI Fundamentals | Start Course β |
| 7 | Foundations of Digital Marketing and E-commerce | Start Course β |
| 8 | Play It Safe: Manage Security Risks | Start Course β |
| 9 | The Bits and Bytes of Computer Networking | Start Course β |
| 10 | Analyze Data to Answer Questions | Start Course β |
| 11 | Automate Cybersecurity Tasks with Python | Start Course β |
| 12 | Architecting with Google Compute Engine | Start Course β |
| 13 | AI for Writing and Communicating | Start Course β |
| 14 | From Likes to Leads: Interact with Customers Online | Start Course β |
| 15 | AI for Data Analysis | Start Course β |
π£ IBM Courses
π Explore SQL, Python, Data Analytics, Deep Learning, RAG and Generative AI resources.
| # | Course | Link |
|---|---|---|
| 1 | Databases and SQL for Data Science with Python | Start Course β |
| 2 | RAG and Agentic AI Capstone Project | Start Course β |
| 3 | Excel Basics for Data Analysis | Start Course β |
| 4 | Introduction to Data Analytics | Start Course β |
| 5 | Data Visualization and Dashboards with Excel and Cognos | Start Course β |
| 6 | IBM AI Foundations for Business | Start Course β |
| 7 | AI Capstone Project with Deep Learning | Start Course β |
| 8 | Python Project for Data Engineering | Start Course β |
| 9 | Building Generative AI-Powered Applications with Python | Start Course β |
| 10 | Vector Databases for RAG: An Introduction | Start Course β |
π₯ Best Courses 2027β2028
π― A broader collection covering AI, Data, Python, Finance, Cybersecurity, Marketing, Networking, Management and Data Engineering.
| # | Course | Link |
|---|---|---|
| 1 | AI For Everyone | Start Course β |
| 2 | Foundations: Data, Data, Everywhere | Start Course β |
| 3 | Ask Questions to Make Data-Driven Decisions | Start Course β |
| 4 | Prepare Data for Exploration | Start Course β |
| 5 | Financial Markets | Start Course β |
| 6 | Agile Project Management | Start Course β |
| 7 | Play It Safe: Manage Security Risks | Start Course β |
| 8 | Project Initiation: Starting a Successful Project | Start Course β |
| 9 | AI Fundamentals | Start Course β |
| 10 | Analyze Data to Answer Questions | Start Course β |
| 11 | Foundations of Digital Marketing and E-commerce | Start Course β |
| 12 | The Bits and Bytes of Computer Networking | Start Course β |
| 13 | Sequence Models | Start Course β |
| 14 | Federal Taxation I: Individuals, Employees, and Sole Proprietors | Start Course β |
| 15 | Designing the Organization | Start Course β |
| 16 | Game Theory | Start Course β |
| 17 | Using Python to Access Web Data | Start Course β |
| 18 | Viral Marketing and How to Craft Contagious Content | Start Course β |
| 19 | Python Project for Data Engineering | Start Course β |
| 20 | Value Chain Management | Start Course β |
| 21 | Applying Data Analytics in Finance | Start Course β |
π Learning & Career Resources
π‘ Additional resources for learning, career development, language learning, hosting, education and professional growth.
πΊοΈ Recommended Learning Roadmaps
Choose one roadmap according to your career goal. You don't need to learn everything at once.
π€ AI Roadmap
AI Fundamentals
β
Python Basics
β
Mathematics & Statistics
β
Data Fundamentals
β
Machine Learning
β
Deep Learning
β
Generative AI
β
Prompt Engineering
β
RAG
β
Vector Databases
β
Agentic AI
β
AI Applications
β
Real-World Projects
β
GitHub Portfolio






