Complete list of Docker CLI commands
Updated:
General Commands
Command | Description |
---|---|
docker version | Show Docker version |
docker info | Display system-wide information |
docker help | Show help for commands |
Container Management
Command | Description |
---|---|
docker run -it --name mycontainer alpine sh | Run a container interactively |
docker start <container> | Start a stopped container |
docker stop <container> | Stop a running container |
docker restart <container> | Restart a container |
docker pause <container> | Pause a container |
docker unpause <container> | Resume a paused container |
docker rm <container> | Remove a container |
docker ps | List running containers |
docker ps -a | List all containers (including stopped ones) |
docker inspect | Show detailed information about a container |
docker logs | Show logs from a container |
docker top | Show running processes in a container |
docker stats | Show real-time resource usage of containers |
docker exec -it | Run a command inside a running container |
docker attach | Attach to a running container’s output |
Image Management
Command | Description |
---|---|
docker images | List available images |
docker pull <image> | Download an image from a registry |
docker push <image> | Upload an image to a registry |
docker build -t myimage . | Build an image from a Dockerfile |
docker rmi <image> | Remove an image |
docker tag <image> myrepo/myimage:v1 | Tag an image for pushing to a registry |
docker save -o myimage.tar <image> | Save an image as a tar archive |
docker load -i myimage.tar | Load an image from a tar archive |
docker history <image> | Show the history of an image |
Network Management
Command | Description |
---|---|
docker network ls | List available networks |
docker network create mynetwork | Create a new network |
docker network inspect <network> | Inspect a network |
docker network rm <network> | Remove a network |
docker network connect <network> <container> | Connect a container to a network |
docker network disconnect <network> <container> | Disconnect a container from a network |
Volume Management
Command | Description |
---|---|
docker volume ls | List volumes |
docker volume create myvolume | Create a new volume |
docker volume inspect <volume> | Inspect a volume |
docker volume rm <volume> | Remove a volume |
Container Cleanup
Command | Description |
---|---|
docker system prune -a | Remove all unused containers, networks, images, and volumes |
docker rm $(docker ps -aq) | Remove all stopped containers |
docker rmi $(docker images -q) | Remove all images |
docker volume rm $(docker volume ls -q) | Remove all volumes |