Mastering Docker Commands: A Comprehensive Cheat Sheet for Every User

  1. docker run: Run a container from an image.

     docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
    
  2. docker ps: List running containers.

     docker ps [OPTIONS]
    
  3. docker build: Build an image from a Dockerfile.

     docker build [OPTIONS] PATH | URL | -
    
  4. docker stop: Stop one or more running containers.

     docker stop [OPTIONS] CONTAINER [CONTAINER...]
    
  5. docker pull: Pull an image or a repository from a registry.

     docker pull [OPTIONS] NAME[:TAG|@DIGEST]
    
  6. docker images: List images.

     docker images [OPTIONS] [REPOSITORY[:TAG]]
    
  7. docker rm: Remove one or more containers.

     docker rm [OPTIONS] CONTAINER [CONTAINER...]
    
  8. docker rmi: Remove one or more images.

     docker rmi [OPTIONS] IMAGE [IMAGE...]
    
  9. docker exec: Run a command in a running container.

     docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
    
  10. docker volume ls: List volumes.

    docker volume ls [OPTIONS]
    
  11. docker network ls: List networks.

    docker network ls [OPTIONS]
    
  12. docker-compose up: Build and start containers defined in the docker-compose.yml file.

    docker-compose up [options] [--scale SERVICE=NUM...]
    
  13. docker-compose down: Stop and remove containers, networks, images, and volumes defined in the docker-compose.yml file.

    docker-compose down [options]
    
  14. docker logs: Fetch the logs of a container.

    docker logs [OPTIONS] CONTAINER
    
  15. docker inspect: Return low-level information on Docker objects.

    docker inspect [OPTIONS] NAME|ID [NAME|ID...]
    
  16. docker tag: Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE.

    docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
    
  17. docker push: Push an image or a repository to a registry.

    docker push [OPTIONS] NAME[:TAG]
    
  18. docker-compose build: Build or rebuild services.

    docker-compose build [options] [SERVICE...]
    
  19. docker-compose start: Start services defined in the docker-compose.yml file.

    docker-compose start [options] [SERVICE...]
    
  20. docker-compose stop: Stop services defined in the docker-compose.yml file.

    docker-compose stop [options] [SERVICE...]
    
  21. docker-compose restart: Restart services defined in the docker-compose.yml file.

    docker-compose restart [options] [SERVICE...]
    
  22. docker-compose pause: Pause services.

    docker-compose pause [SERVICE...]
    
  23. docker-compose unpause: Unpause services.

    docker-compose unpause [SERVICE...]
    
  24. docker-compose logs: View output from services.

    docker-compose logs [options] [SERVICE...]
    
  25. docker-compose pull: Pulls images for services.

    docker-compose pull [options] [SERVICE...]
    
  26. docker-compose exec: Execute a command in a running container.

    docker-compose exec [options] SERVICE COMMAND [ARGS...]
    
  27. docker-compose scale: Set number of containers for a service.

    docker-compose scale [SERVICE=NUM...]
    
  28. docker-compose top: Display the running processes.

    docker-compose top [SERVICE...]
    
  29. docker-compose ps: List containers.

    docker-compose ps [options] [SERVICE...]
    
  30. docker-compose events: Receive real time events from containers.

    docker-compose events [options]
    
  31. docker-compose port: Print the public port for a port binding.

    docker-compose port SERVICE PRIVATE_PORT
    
  32. docker-compose config: Validate and view the Compose file.

    docker-compose config [options]
    
  33. docker-compose version: Show the Docker-Compose version information.

    docker-compose version [options]
    
  34. docker-compose help: Get help on a command.

    docker-compose help [COMMAND]
    
  35. docker-compose create: Create services.

    docker-compose create [options]
    
  36. docker-compose push: Push services to the registry.

    docker-compose push [options]
    
  37. docker-compose images: List images used by the created services.

    docker-compose images [options]
    
  38. 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.

0
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 |