Docker Commands with Uses
Docker Basics
• docker --version: Check installed Docker version.
• docker info: Display system-wide information about Docker.
• docker help: List all available Docker commands.
Images
• docker images: List all images on local machine.
• docker pull : Download an image from Docker Hub.
• docker rmi : Remove an image from local machine.
• docker build -t .: Build an image from a Dockerfile.
Containers
• docker ps: List running containers.
• docker ps -a: List all containers (running + stopped).
• docker run : Create and start a new container from an image.
• docker start : Start a stopped container.
• docker stop : Stop a running container.
• docker restart : Restart a container.
• docker rm : Remove a container.
Container Interaction
• docker logs : Fetch logs of a container.
• docker exec -it /bin/bash: Access container shell.
• docker attach : Attach terminal to a running container.
• docker cp : : Copy files from container to host.
Volumes
• docker volume ls: List all Docker volumes.
• docker volume create : Create a new volume.
• docker volume rm : Remove a volume.
Networks
• docker network ls: List all Docker networks.
• docker network create : Create a new network.
• docker network rm : Remove a network.
• docker network inspect : View details of a network.
Docker Compose
• docker-compose up: Start services defined in docker-compose.yml.
• docker-compose down: Stop and remove containers, networks, and volumes created by
compose.
• docker-compose ps: List containers managed by Compose.
• docker-compose logs: View logs of services managed by Compose.
Docker System Management
• docker system df: Show Docker disk usage.
• docker system prune: Remove unused data (containers, images, networks).
• docker system info: Display detailed system-wide information.