🛠️ Mastering Docker Commands: Your Daily Toolkit

Published: (December 7, 2025 at 10:13 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

Cover image for 🛠️ Mastering Docker Commands: Your Daily Toolkit

You’ve learned the what, why, and how behind Docker’s architecture and filesystem. Now, let’s get deeply practical with the commands you’ll use every single day to interact with Docker. This post will be your go‑to reference for managing images, containers, and your Docker environment.

We’ve organized the essential commands into categories for easy lookup.

🔍 Docker System & Information Commands

CommandDescriptionExample
docker --versionDisplays the Docker client version.docker --version
docker infoProvides detailed system‑wide information about your Docker installation.docker info
docker system dfShows disk space usage by Docker objects (images, containers, volumes).docker system df
docker system pruneRemoves unused Docker data (stopped containers, unused networks, dangling images).docker system prune

🖼️ Image Management Commands

CommandDescriptionExample
docker pullDownloads an image from a registry (default is Docker Hub) to your local machine.docker pull ubuntu:latest
docker images / docker image lsLists all images stored locally on your machine.docker images
docker searchSearches Docker Hub for images based on a keyword.docker search nginx
docker inspectDisplays detailed JSON configuration information about a Docker object.docker inspect nginx:latest
docker rmiRemoves one or more images.docker rmi ubuntu:latest

🚢 Container Lifecycle Commands

CommandDescriptionExample
docker runCreates and starts a new container from an image.docker run -it --name my-alpine alpine sh
docker createCreates a container but does not start it.docker create --name my-db postgres
docker startStarts one or more stopped containers.docker start my-db
docker stopStops one or more running containers gracefully.docker stop my-web-server
docker restartRestarts one or more containers.docker restart my-db
docker killKills one or more running containers forcefully (sends SIGKILL).docker kill my-db
docker ps / docker container lsLists running containers. Add -a/--all to list all containers.docker ps -a
docker rmRemoves one or more stopped containers. Use -f to force removal of a running container.docker rm my-alpine

docker run Options (Flags)

OptionMeaningExample Use
-itInteractive mode (-i interactive, -t TTY). Essential for shell access.docker run -it alpine sh
-dDetached mode. Runs the container in the background.docker run -d nginx
-p <hostPort>:<containerPort>Port mapping. Publishes a container’s port to a host port.docker run -p 8080:80 nginx
--name <name>Assigns a memorable name to the container.docker run --name my-app …
--rmAutomatically removes the container when it exits. Great for temporary tasks.docker run --rm alpine …
-v <hostPath>:<containerPath>Volume mount. Mounts a host path or named volume for data persistence.docker run -v my-data:/data …

🔬 Container Interaction & Monitoring Commands

CommandDescriptionExample
docker execExecutes a command inside a running container.docker exec -it my-app sh
docker logsFetches the logs of a container. Use -f to stream logs in real‑time.docker logs -f my-web-server
docker topDisplays the running processes within a container.docker top my-web-server
docker statsShows a live stream of resource usage (CPU, memory, I/O) for running containers.docker stats
docker cpCopies files/folders between a container and the local filesystem.docker cp my-app:/app/config.ini .
docker attachAttaches your terminal to a running container’s streams (use with caution).docker attach my-alpine

You now have a robust toolkit and reference guide for managing every aspect of a container’s life.

In our next post, we will finally use this command‑line knowledge to build custom images. We’ll dive into the architecture of a Dockerfile and practice writing efficient instructions!

Back to Blog

Related posts

Read more »

What is DevOps?

Introduction If you search “What is DevOps?” online, you’ll find many complex definitions. In this article we’ll explain DevOps from the ground up. DevOps = De...