DOCKER CHEATSHEET

Viewing Resource Information

Images

docker images # list all images on the system
docker image ls -a # list all images, including intermediate layers
docker image inspect <image-id> # display detailed information about an image
docker image history <image-id> # show the history of an image
docker image rm <image-id> # remove an image

Containers

docker ps # list running containers
docker ps -a # list all containers, including stopped ones
docker inspect <container-id> # display detailed information about a container
docker logs <container-id> # display logs of a container
docker logs -f <container-id> # follow logs of a container in real-time
docker top <container-id> # display running processes in a container

Managing Resources

Containers

docker run -d --name <container-name> <image-name> # run a container in detached mode
docker run -it --name <container-name> <image-name> /bin/bash # run a container with an interactive shell
docker start <container-id> # start a stopped container
docker stop <container-id> # stop a running container
docker rm <container-id> # remove a container
docker exec -it <container-id> /bin/bash # execute a command in a running container with an interactive shell

Images

docker build -t <image-name> . # build an image from a Dockerfile in the current directory
docker pull <image-name> # pull an image from a registry
docker push <image-name> # push an image to a registry

Networks

docker network ls # list all networks
docker network create <network-name> # create a new network
docker network rm <network-name> # remove a network
docker network inspect <network-name> # display detailed information about a network

Volumes

docker volume ls # list all volumes
docker volume create <volume-name> # create a new volume
docker volume rm <volume-name> # remove a volume
docker volume inspect <volume-name> # display detailed information about a volume

Docker Compose

Docker Compose Commands

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 containers, networks, and volumes defined in docker-compose.yml
docker-compose ps # list containers defined in docker-compose.yml
docker-compose logs # display logs for all services in docker-compose.yml

System Management

System Commands

docker info # display system-wide information
docker system df # display disk usage by Docker objects
docker system prune # remove unused containers, networks, images, and volumes
docker system prune -a # remove all unused images, not just dangling ones

🙏 Support

Buy Me A Coffee


Developed with ❤️ in India 🇮🇳