Docker Cheat Sheet

Docker Cheat Sheet

Docker is a powerful tool for containerization that enables developers to package applications along with their dependencies into a standardized unit called a container. Whether you're just starting with Docker or need a quick reference, this cheat sheet covers essential Docker commands and concepts to help you navigate through your containerization journey.



Here's a detailed Docker cheat sheet for your reference:

docker --version - Show Docker version.

docker run [OPTIONS] IMAGE [COMMAND]- Run a command in a new container.

docker ps -List running containers.

docker ps -a - List all containers, including stopped ones.

docker images - List all Docker images.

docker pull IMAGE - Pull an image from a registry.

docker build -t NAME:TAG - Build an image from a Dockerfile.

docker push NAME:TAG - Push an image to a registry.

docker exec -it CONTAINER COMMAND - Execute a command in a running container.

docker stop CONTAINER - Stop a running container.

docker start CONTAINER - Start a stopped container.

docker restart CONTAINER - Restart a running container.

docker rm CONTAINER - Remove a stopped container.

docker rm IMAGE - Remove an image.

docker logs CONTAINER - View logs of a container.

docker inspect CONTAINER - Display detailed information about a container or image.

docker commit CONTAINER NEW_IMAGE - Create a new image from a container's changes.

docker tag IMAGE NEW_TAG - Tag an image with a new name.

docker network ls - List all Docker networks.

docker network create NETWORK- Create a new network.

docker network connect NETWORK CONTAINER- Connect a container to a network.

docker volume ls - List all Docker volumes.

docker volume create VOLUME - Create a new volume.

docker volume rm VOLUME - Remove a volume.

docker-compose up -d - Start all services defined in a docker-compose.yml file in detached mode.

docker-compose down - Stop and remove containers, networks, images, and volumes defined in a docker-compose.yml file.

docker-compose logs - View logs of services defined in a docker-compose.yml file.

docker-compose psList containers in a docker-compose.yml file.


Docker is an indispensable tool for modern DevOps practices, enabling the creation, deployment, and management of applications in a streamlined and consistent manner. Mastering these Docker commands will significantly enhance your ability to manage containerized applications efficiently.


要查看或添加评论,请登录

社区洞察

其他会员也浏览了