Cloud Native 5 min read

Master Essential Docker Commands: A Quick Reference for Container Operations

This guide presents a concise, step‑by‑step reference of the most frequently used Docker commands for managing images, containers, troubleshooting, data volumes, networks, and system cleanup, and highlights five core commands that can resolve the majority of everyday container issues.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Master Essential Docker Commands: A Quick Reference for Container Operations

Image Operations

Pull an image from a registry: docker pull nginx:latest List local images: docker images Remove a local image: docker rmi nginx:latest Build a new image from a Dockerfile:

docker build -t myapp:1.0 .

Container Operations

Run a container (most common usage): docker run -d -p 8080:80 --name mynginx nginx Common flags: -d – run in background -p – map host port to container port --name – assign a name to the container -v – mount a volume -e – set environment variables

List running containers: docker ps List all containers (including stopped): docker ps -a Stop a container: docker stop mynginx Start a stopped container: docker start mynginx Restart a container: docker restart mynginx Remove a container: docker rm mynginx Force‑remove a container:

docker rm -f mynginx

Container Troubleshooting

View container logs (follow mode): docker logs -f mynginx Enter a running container for interactive debugging: docker exec -it mynginx /bin/bash Enter an Alpine‑based container: docker exec -it mynginx /bin/sh Inspect detailed container information: docker inspect mynginx Show real‑time resource usage of containers:

docker stats

Data and Network

List Docker volumes: docker volume ls List Docker networks: docker network ls Inspect a specific network (e.g., bridge):

docker network inspect bridge

System Management

Clean up unused resources (images, containers, networks, volumes): docker system prune -a Export an image to a tar archive: docker save -o nginx.tar nginx Import an image from a tar archive: docker load -i nginx.tar Commit a running container as a new image:

docker commit mynginx mynginx:v2

Five Core Commands

If you only remember five Docker commands, they are:

docker run
docker ps
docker logs -f
docker exec -it
docker system prune

These commands can resolve roughly 80 % of common production issues related to containerized services.

CLIDockeroperationscontainer
Mike Chen's Internet Architecture
Written by

Mike Chen's Internet Architecture

Over ten years of BAT architecture experience, shared generously!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.