0% found this document useful (0 votes)
29 views2 pages

Docker Command Cheat Sheet

All are azure notes best

Uploaded by

harshaltapadiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

Docker Command Cheat Sheet

All are azure notes best

Uploaded by

harshaltapadiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DOCKER COMMAND CHEAT SHEET (MASTER LEVEL)

== GENERAL ==
docker version # Show Docker version
docker info # Display system-wide info
docker help # Show help for any command

== IMAGES ==
docker images # List images
docker pull <image> # Download image
docker build -t <name>:<tag> . # Build image from Dockerfile
docker rmi <image> # Remove image
docker tag <src> <target> # Tag an image
docker save -o <file>.tar <image> # Save image to tarball
docker load -i <file>.tar # Load image from tarball

== CONTAINERS ==
docker ps # List running containers
docker ps -a # List all containers
docker run -d -p 80:80 <image> # Run container detached
docker run -it <image> /bin/bash # Interactive shell
docker exec -it <container> <cmd> # Run command in running container
docker logs <container> # Show container logs
docker stop <container> # Stop container
docker start <container> # Start container
docker restart <container> # Restart container
docker rm <container> # Remove container
docker rename <old> <new> # Rename container

== VOLUMES ==
docker volume create <name> # Create volume
docker volume ls # List volumes
docker volume inspect <name> # Inspect volume
docker volume rm <name> # Remove volume
docker run -v <vol>:/data <image> # Mount volume

== NETWORKING ==
docker network ls # List networks
docker network create <name> # Create custom network
docker network inspect <name> # Inspect network
docker network rm <name> # Remove network
docker run --network=<name> <image> # Run with custom network

== DOCKERFILE ==
FROM <base-image> # Base image
RUN <command> # Run command at build
COPY <src> <dest> # Copy files
ADD <src> <dest> # Copy files (also extract archives)
CMD ["executable", "arg"] # Default container command
ENTRYPOINT ["executable", "arg"] # Command with fixed entry
EXPOSE <port> # Document port
ENV <key>=<val> # Environment variable
VOLUME ["/data"] # Mount point

== CLEANUP ==
docker system df # Show disk usage
docker system prune # Remove unused data
docker image prune # Remove unused images
docker container prune # Remove stopped containers
docker volume prune # Remove unused volumes

== ADVANCED ==
docker inspect <object> # Detailed info on image/container
docker stats # Real-time resource usage
docker top <container> # Show running processes
docker cp <container>:<path> <host_path> # Copy from container
docker cp <host_path> <container>:<path> # Copy to container
docker login # Authenticate to registry
docker push <image> # Push image to registry
docker commit <container> <image> # Commit container to image

== DOCKER COMPOSE ==
docker-compose up -d # Start services in background
docker-compose down # Stop and remove services
docker-compose build # Build images
docker-compose logs # View logs
docker-compose exec <service> <cmd> # Exec into service container

You might also like