Docker
Docker
Docker is a platform for developing, shipping, and running applications in containers. It enables you to separate your applications from your infrastructure so you can deliver software quickly.
Docker Version
Display Docker version information
docker --version
Docker Info
Display system-wide information about Docker
docker info
List Docker Images
List all Docker images
docker images
Pull Docker Image
Pull an image from a registry
docker pull image_name:tag
Remove Docker Image
Remove an image
docker rmi image_name:tag
Remove All Unused Images
Remove all unused images
docker image prune -a
Build Docker Image
Build an image from a Dockerfile
docker build -t image_name:tag .
Build Docker Image (No Cache)
Build an image from a Dockerfile without using cache
docker build --no-cache -t image_name:tag .
List Running Containers
List running containers
docker ps
List All Containers
List all containers (including stopped ones)
docker ps -a
Run Docker Container
Run a container in detached mode
docker run -d --name container_name image_name:tag
Run Docker Container (Interactive)
Run a container in interactive mode with a shell
docker run -it --name container_name image_name:tag /bin/bash
Run Docker Container (With Port Mapping)
Run a container with port mapping
docker run -d -p 8080:80 --name container_name image_name:tag
Run Docker Container (With Volume)
Run a container with a volume mount
docker run -d -v /host/path:/container/path --name container_name image_name:tag
Run Docker Container (With Environment Variables)
Run a container with environment variables
docker run -d -e "KEY=value" --name container_name image_name:tag
Stop Docker Container
Stop a running container
docker stop container_name
Start Docker Container
Start a stopped container
docker start container_name
Restart Docker Container
Restart a container
docker restart container_name
Remove Docker Container
Remove a container
docker rm container_name
Remove Running Docker Container
Force remove a running container
docker rm -f container_name
Remove All Stopped Containers
Remove all stopped containers
docker container prune
View Container Logs
View logs of a container
docker logs container_name
View Container Logs (Follow)
Follow logs of a container
docker logs -f container_name
Execute Command in Container
Execute a command in a running container
docker exec -it container_name /bin/bash
Copy File from Container
Copy a file from a container to the host
docker cp container_name:/container/path /host/path
Copy File to Container
Copy a file from the host to a container
docker cp /host/path container_name:/container/path
Inspect Container
Display detailed information about a container
docker inspect container_name
View Container Resource Usage
Display resource usage statistics for containers
docker stats
View Container Resource Usage (One Container)
Display resource usage statistics for a specific container
docker stats container_name
List Docker Networks
List all Docker networks
docker network ls
Create Docker Network
Create a Docker network
docker network create network_name
Connect Container to Network
Connect a container to a network
docker network connect network_name container_name
Disconnect Container from Network
Disconnect a container from a network
docker network disconnect network_name container_name
Remove Docker Network
Remove a Docker network
docker network rm network_name
Inspect Docker Network
Display detailed information about a network
docker network inspect network_name
List Docker Volumes
List all Docker volumes
docker volume ls
Create Docker Volume
Create a Docker volume
docker volume create volume_name
Remove Docker Volume
Remove a Docker volume
docker volume rm volume_name
Remove All Unused Volumes
Remove all unused volumes
docker volume prune
Inspect Docker Volume
Display detailed information about a volume
docker volume inspect volume_name
Docker Compose Up
Start services defined in docker-compose.yml
docker-compose up -d
Docker Compose Down
Stop and remove services defined in docker-compose.yml
docker-compose down
Docker Compose Build
Build services defined in docker-compose.yml
docker-compose build
Docker Compose Logs
View logs of services defined in docker-compose.yml
docker-compose logs
Docker Compose Logs (Follow)
Follow logs of services defined in docker-compose.yml
docker-compose logs -f
Docker Compose Ps
List containers for services defined in docker-compose.yml
docker-compose ps
Docker Compose Exec
Execute a command in a service defined in docker-compose.yml
docker-compose exec service_name command
Docker Compose Restart
Restart services defined in docker-compose.yml
docker-compose restart
Docker Compose Pull
Pull images for services defined in docker-compose.yml
docker-compose pull
Docker System Prune
Remove all unused containers, networks, images, and volumes
docker system prune
Docker System Prune (All)
Remove all unused containers, networks, images, and volumes (including unused images)
docker system prune -a
Docker System DF
Display Docker disk usage
docker system df
Docker Login
Log in to a Docker registry
docker login
Docker Logout
Log out from a Docker registry
docker logout
Docker Tag
Tag an image
docker tag source_image:tag target_image:tag
Docker Push
Push an image to a registry
docker push image_name:tag