Images
docker images
List all local images
docker pull <image>
Pull an image from registry
docker push <image>
Push an image to registry
docker build -t <name> .
Build an image from Dockerfile
docker tag <id> <name>
Tag an image with a name
docker rmi <image>
Remove an image
docker inspect <image>
Show detailed image information
docker search <term>
Search Docker Hub for images
docker history <image>
Show image layer history
Containers
docker run <image>
Create and run a container
docker run -d <image>
Run container in detached mode
docker run -it <image> bash
Run container interactively with bash
docker run -p 8080:80 <image>
Map port 8080 to container port 80
docker run -v /host:/container <image>
Mount volume from host to container
docker run -e VAR=value <image>
Set environment variable in container
docker run --name <name> <image>
Run container with custom name
docker ps
List running containers
docker ps -a
List all containers (running and stopped)
docker start <container>
Start a stopped container
docker stop <container>
Stop a running container
docker restart <container>
Restart a container
docker rm <container>
Remove a container
docker kill <container>
Force stop a container
docker exec -it <container> bash
Execute command inside running container
docker logs <container>
View container logs
docker logs -f <container>
Follow container logs in real-time
docker inspect <container>
Show detailed container information
docker stats <container>
Show container CPU and memory usage
Networks
docker network ls
List all networks
docker network create <name>
Create a new network
docker network connect <net> <container>
Connect container to network
docker network disconnect <net> <container>
Disconnect container from network
docker network inspect <network>
Show network details
docker network rm <network>
Remove a network
Docker Compose
docker-compose up
Start services defined in docker-compose.yml
docker-compose up -d
Start services in detached mode
docker-compose down
Stop and remove services
docker-compose ps
List services and their status
docker-compose logs
View logs from services
docker-compose exec <service> bash
Execute command in service container
docker-compose build
Build images for services
docker-compose pull
Pull images for services
Debugging & Inspection
docker attach <container>
Attach to running container output
docker diff <container>
Show filesystem changes in container
docker cp <container>:<path> <host>
Copy files from container to host
docker commit <container> <image>
Create image from container
Cleanup
docker prune
Remove unused containers, images, volumes
docker container prune
Remove stopped containers
docker image prune
Remove dangling images
docker system prune -a
Remove all unused images, containers, networks