Docker cheat sheet with the top 50 commands:
- docker pull [image_name]: Pull an image from Docker Hub.
- docker images: List all images available locally.
- docker rmi [image_id/name]: Remove an image.
- docker run [options] [image_name]: Run a container from an image.
- docker ps: List running containers.
- docker ps -a: List all containers (both running and stopped).
- docker start [container_id/name]: Start a stopped container.
- docker stop [container_id/name]: Stop a running container.
- docker rm [container_id/name]: Remove a container.
- docker logs [container_id/name]: View logs of a container.
- docker inspect [container_id/name/image_id]: Display detailed information about a container or image.
- docker exec [options] [container_id/name] [command]: Execute a command in a running container.
- docker build [options] [path]: Build an image from a Dockerfile.
- docker tag [image_id/name] [new_image_name]: Tag an image with a new name.
- docker push [image_name]: Push an image to Docker Hub.
- docker volume ls: List all volumes.
- docker volume create [volume_name]: Create a volume.
- docker volume rm [volume_name]: Remove a volume.
- docker network ls: List all networks.
- docker network create [network_name]: Create a network.
- docker network rm [network_name]: Remove a network.
- docker-compose up: Create and start containers defined in the docker-compose.yml file.
- docker-compose down: Stop and remove containers defined in the docker-compose.yml file.
- docker-compose build: Build or rebuild services defined in the docker-compose.yml file.
- docker-compose logs [service_name]: View logs of a specific service.
- docker-compose exec [service_name] [command]: Execute a command in a running service container.
- docker pause [container_id/name]: Pause a running container.
- docker unpause [container_id/name]: Unpause a paused container.
- docker rename [old_container_name] [new_container_name]: Rename a container.
- docker update [options] [container_id/name]: Update configuration of one or more containers.
- docker version: Check Docker version.
- docker info: Display Docker system-wide information.
- docker search [term]: Search for an image on Docker Hub.
- docker login: Log in to a Docker registry.
- docker logout: Log out from a Docker registry.
- docker commit [container_id/name] [new_image_name]: Create a new image from a container's changes.
- docker stats: Display a live stream of container resource usage statistics.
- docker events: Get real-time events from the Docker server.
- docker system df: Show Docker disk usage.
- docker system prune: Remove all unused containers, networks, volumes, and images.
- docker port [container_id/name]: List port mappings or a specific mapping for a container.
- docker top [container_id/name]: Display the running processes of a container.
- docker wait [container_id/name]: Block until a container stops, then print its exit code.
- docker swarm init: Initialize a Docker Swarm.
- docker swarm join: Join a Docker Swarm as a worker or manager node.
- docker node ls: List nodes in the Docker Swarm.
- docker service ls: List services in the Docker Swarm.
- docker service create: Create a new service in the Docker Swarm.
- docker service scale: Scale a service in the Docker Swarm.
- docker stack deploy: Deploy a new stack or update an existing stack in the Docker Swarm.
These commands cover a wide range of Docker operations and should serve as a useful reference for Docker users.
?I help Businesses Upskill their Employees in DevOps | DevOps Mentor & Process Architect
1 年Priyanka kumari, I just checked out your Docker cheat sheet, and I have to say, it's really helpful! But I'm curious, what's your favorite command to use in your Docker workflow?