/docker
Docker command reference
Daily Docker commands for running, inspecting, and maintaining containers.
Containers
15 commands
docker run <image>Run a container from an image.
docker run -it <image> bashRun interactively with a terminal shell.
docker run -d <image>Run a container in the background.
docker psList running containers.
docker ps -aList all containers, including stopped ones.
docker stop <container>Stop a running container.
docker start <container>Start a stopped container.
docker restart <container>Restart a container.
docker rm <container>Remove a container.
docker rm -f <container>Force remove a container, even if it is running.
docker exec -it <container> bashOpen a shell inside a running container.
Note: Use `sh` instead of `bash` on minimal images like Alpine.
docker logs <container>View container logs.
docker logs -f <container>Follow logs in real time.
docker inspect <container>Show detailed container metadata.
docker statsDisplay live resource usage for containers.
Images
7 commands
docker imagesList images stored locally.
docker pull <image>Download an image from a registry.
docker build -t <name> .Build an image from the current Dockerfile.
docker rmi <image>Remove an image.
docker image pruneRemove unused images.
docker tag <image> <new_name>Tag an image with a new name.
docker push <image>Push an image to a registry.
Volumes
5 commands
docker volume create <name>Create a named volume.
docker volume lsList all volumes.
docker volume inspect <name>Show details about a volume.
docker volume rm <name>Remove a volume.
docker volume pruneRemove unused volumes.
Networks
4 commands
docker network lsList Docker networks.
docker network create <name>Create a new network.
docker network rm <name>Remove a network.
docker network inspect <name>Show detailed network information.
System Cleanup
3 commands
docker system pruneRemove unused containers, networks, and dangling images.
docker system prune -aRemove all unused data, including unused images.
docker container pruneRemove all stopped containers.
Docker Compose
7 commands
docker compose upStart services from a compose file.
docker compose up -dStart services in detached mode.
docker compose downStop and remove services.
docker compose psList compose-managed services.
docker compose logsShow logs for compose services.
docker compose buildBuild or rebuild compose services.
docker compose restartRestart compose services.
Misc
4 commands
docker versionShow Docker client and server version information.
docker infoDisplay system-wide Docker information.
docker loginLog in to a Docker registry.
docker logoutLog out from the current registry session.