Top 50 Docker commands, grouped by their primary functions :

Top 50 Docker commands, grouped by their primary functions :

Managing Containers :

  1. Run a Container :

     docker run [OPTIONS] IMAGE [COMMAND] [ARGS]
    
  2. List Running Containers :

     docker ps
    
  3. List All Containers (including stopped ones) :

     docker ps -a
    
  4. Start a Stopped Container :

     docker start CONTAINER_ID
    
  5. Stop a Running Container :

     docker stop CONTAINER_ID
    
  6. Restart a Container :

     docker restart CONTAINER_ID
    
  7. Remove a Container (stop and delete) :

     docker rm CONTAINER_ID
    
  8. Execute a Command in a Running Container :

     docker exec [OPTIONS] CONTAINER_ID|NAME [COMMAND] [ARGS]
    
  9. Inspect Container Details :

     docker inspect CONTAINER_ID
    
  10. Attach to a Running Container's STDIN, STDOUT, and STDERR :

    docker attach CONTAINER_ID
    

Managing Images :

  1. List Docker Images :

     docker images
    
  2. Pull an Image from a Registry :

     docker pull IMAGE_NAME[:TAG]
    
  3. Build an Image from a Dockerfile :

     docker build [OPTIONS] PATH_TO_DOCKERFILE
    
  4. Tag an Image :

     docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
    
  5. Remove an Image :

     docker rmi IMAGE_ID
    
  6. Search for Images on Docker Hub :

     docker search IMAGE_NAME
    
  7. Save an Image to a Tarball File :

     docker save -o OUTPUT_FILE.tar IMAGE_NAME[:TAG]
    
  8. Load an Image from a Tarball File :

     docker load -i INPUT_FILE.tar
    

Managing Docker Volumes :

  1. List Docker Volumes :

     docker volume ls
    
  2. Create a Docker Volume :

     docker volume create VOLUME_NAME
    
  3. Inspect a Docker Volume :

     docker volume inspect VOLUME_NAME
    
  4. Remove a Docker Volume :

     docker volume rm VOLUME_NAME
    

Managing Networks :

  1. List Docker Networks :

     docker network ls
    
  2. Create a Docker Network :

     docker network create NETWORK_NAME
    
  3. Inspect a Docker Network :

     docker network inspect NETWORK_NAME
    
  4. Remove a Docker Network :

     docker network rm NETWORK_NAME
    

Managing Docker Compose :

  1. Start Docker Compose Services :

     docker-compose up [OPTIONS] [SERVICE...]
    
  2. Stop Docker Compose Services :

     docker-compose down [OPTIONS]
    
  3. Build or Rebuild Docker Compose Services :

     docker-compose build [SERVICE...]
    
  4. View Docker Compose Logs :

     docker-compose logs [SERVICE...]
    

Docker Registry and Authentication :

  1. Login to a Docker Registry :

     docker login [OPTIONS] [SERVER]
    
  2. Logout from a Docker Registry :

     docker logout [SERVER]Miscellaneous Commands:
    

Miscellaneous Commands :

  1. View Docker Version Info :

     docker version
    
  2. Check Docker System Information :

     docker info
    
  3. Display Docker Disk Usage :

     docker system df
    
  4. Monitor Docker Events :

     docker events [OPTIONS]
    
  5. Pull and Apply Updates to Docker Swarm Services :

     docker service update [OPTIONS] SERVICE
    
  6. Clean Up Unused Resources (Containers, Images, Volumes, Networks) :

     docker system prune
    
  7. Pause a Running Container :

     docker pause CONTAINER_ID
    
  8. Unpause a Paused Container :

     docker unpause CONTAINER_ID
    
  9. Inspect Docker Daemon Logs :

     docker logs docker
    

Docker Swarm (Container Orchestration) :

  1. Initialize a Docker Swarm :

     docker swarm init [OPTIONS]
    
  2. Join a Node to a Docker Swarm :

     docker swarm join [OPTIONS] HOST:PORT
    
  3. List Nodes in a Docker Swarm :

     docker node ls
    
  4. Create a Docker Service :

     docker service create [OPTIONS] IMAGE [COMMAND] [ARGS]
    
  5. List Docker Services :

     docker service ls
    
  6. Scale a Docker Service :

     docker service scale SERVICE=REPLICAS
    
  7. Inspect a Docker Service :

     docker service inspect SERVICE
    
  8. Remove a Docker Service :

     docker service rm SERVICE
    
  9. Leave a Docker Swarm (Node) :

     docker swarm leave [OPTIONS]
    

These are some of the most commonly used Docker commands for managing containers, images, volumes, networks, and Docker Swarm. Depending on your specific use case, you may need to use additional commands and options to tailor Docker to your needs.