Docker

Container Management

Command Description
docker run -d --name <name> -p 8080:80 <image> Create and run a named container in the background with port mapping.
docker run -it --rm <image> /bin/bash Start an interactive shell in a temporary container that deletes itself upon exit.
docker ps -a List all running and stopped containers (omit -a for running only).
docker exec -it <container> /bin/bash Open an interactive terminal inside an already running container.
docker logs -f <container> Stream real-time logs from a container.
docker start / stop <container> Start a stopped container or gracefully stop a running one.
docker rm -f <container> Force remove a container, even if it is currently running.
docker stats Display a live stream of container CPU, memory, and network usage.

Image Management

Command Description
docker build -t <name>:<tag> . Build an image from a Dockerfile in the current directory.
docker images List all locally stored images.
docker pull <image>:<tag> Download an image from a remote registry.
docker push <user>/<image>:<tag> Upload a local image to a remote registry.
docker rmi <image> Delete a local image.
docker image prune Remove unused and dangling images to free up disk space.

Volumes & Networks

Command Description
docker volume create <name> Create a named volume for persistent data storage.
docker volume ls List all existing Docker volumes.
docker run -v <vol>:/path <image> Mount a named volume to a specific path inside a container.
docker network create <name> Create an isolated bridge network for container communication.
docker network inspect <name> View detailed configuration and connected containers for a network.
docker system prune -a Delete all stopped containers, unused networks, and unreferenced images.

Docker Compose

Command Description
docker compose up -d Build images and start all defined services in the background.
docker compose down Stop all services and remove containers and default networks (add -v for volumes).
docker compose ps List the status of containers managed by Compose.
docker compose logs -f <service> Monitor live output from a specific service.