Mastering Docker Commands: A Comprehensive Cheat Sheet for Every User
docker run: Run a container from an image.
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
docker ps: List running containers.
docker ps [OPTIONS]
docker build: Build an image from a Dockerfile.
docker build [OPTIONS] PATH | URL | -
docker stop: Stop one or more running containers.
docker stop [OPTIONS] CONTAINER [CONTAINER...]
docker pull: Pull an image or a repository from a registry.
docker pull [OPTIONS] NAME[:TAG|@DIGEST]
docker images: List images.
docker images [OPTIONS] [REPOSITORY[:TAG]]
docker rm: Remove one or more containers.
docker rm [OPTIONS] CONTAINER [CONTAINER...]
docker rmi: Remove one or more images.
docker rmi [OPTIONS] IMAGE [IMAGE...]
docker exec: Run a command in a running container.
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
docker volume ls: List volumes.
docker volume ls [OPTIONS]
docker network ls: List networks.
docker network ls [OPTIONS]
docker-compose up: Build and start containers defined in the docker-compose.yml file.
docker-compose up [options] [--scale SERVICE=NUM...]
docker-compose down: Stop and remove containers, networks, images, and volumes defined in the docker-compose.yml file.
docker-compose down [options]
docker logs: Fetch the logs of a container.
docker logs [OPTIONS] CONTAINER
docker inspect: Return low-level information on Docker objects.
docker inspect [OPTIONS] NAME|ID [NAME|ID...]
docker tag: Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE.
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
docker push: Push an image or a repository to a registry.
docker push [OPTIONS] NAME[:TAG]
docker-compose build: Build or rebuild services.
docker-compose build [options] [SERVICE...]
docker-compose start: Start services defined in the docker-compose.yml file.
docker-compose start [options] [SERVICE...]
docker-compose stop: Stop services defined in the docker-compose.yml file.
docker-compose stop [options] [SERVICE...]
docker-compose restart: Restart services defined in the docker-compose.yml file.
docker-compose restart [options] [SERVICE...]
docker-compose pause: Pause services.
docker-compose pause [SERVICE...]
docker-compose unpause: Unpause services.
docker-compose unpause [SERVICE...]
docker-compose logs: View output from services.
docker-compose logs [options] [SERVICE...]
docker-compose pull: Pulls images for services.
docker-compose pull [options] [SERVICE...]
docker-compose exec: Execute a command in a running container.
docker-compose exec [options] SERVICE COMMAND [ARGS...]
docker-compose scale: Set number of containers for a service.
docker-compose scale [SERVICE=NUM...]
docker-compose top: Display the running processes.
docker-compose top [SERVICE...]
docker-compose ps: List containers.
docker-compose ps [options] [SERVICE...]
docker-compose events: Receive real time events from containers.
docker-compose events [options]
docker-compose port: Print the public port for a port binding.
docker-compose port SERVICE PRIVATE_PORT
docker-compose config: Validate and view the Compose file.
docker-compose config [options]
docker-compose version: Show the Docker-Compose version information.
docker-compose version [options]
docker-compose help: Get help on a command.
docker-compose help [COMMAND]
docker-compose create: Create services.
docker-compose create [options]
docker-compose push: Push services to the registry.
docker-compose push [options]
docker-compose images: List images used by the created services.
docker-compose images [options]
docker-compose kill: Force stop service containers.
docker-compose kill [options]
These commands provide a comprehensive set of tools for managing Docker containers, images, networks, and volumes both individually and through Docker Compose.
Subscribe to my newsletter
Read articles from Vaishnavi Shivde directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Vaishnavi Shivde
Vaishnavi Shivde
Aspiring DevOps Engineer | Linux | Git & Github | Shell Scripting | Docker | CI/CD Jenkins | Kubernetes | AWS | Terraform | JIRA | Python |