Top 50 Docker Commands for Daily Use

Docker commands

In the world of DevOps and containerization, Docker has become an essential tool for developers, system administrators, and even beginners. It’s powerful, flexible, and, when used effectively, can drastically speed up your workflows. In this guide, we’ll take you through the top 50 Docker commands you’ll need on a daily basis to manage containers, images, volumes, and more!

What is Docker?

Docker commands

Before we dive into the commands, let’s have a brief overview. Docker is a platform that allows you to automate the deployment of applications inside lightweight, portable containers. Containers encapsulate an application and its dependencies, ensuring it runs the same everywhere.

For a more detailed explanation of configuring Docker, check out this guide on common Dockerfile and YAML configurations.

Why You Need These Commands

Whether you’re a seasoned Docker user or just starting, having a go-to list of Docker CLI commands is crucial for working efficiently. These Docker container commands will help you manage containers, images, networks, and volumes without hassle. Understanding the Docker daily use commands will save you time and make your workflows smoother.


Docker Commands Cheat Sheet

Here’s a list of the most important Docker commands you’ll find yourself using daily:

Basic Docker Commands

  1. docker --version
    Check the version of Docker installed on your system.
  2. docker info
    Get system-wide information about Docker including containers, images, and volumes.
  3. docker help
    Displays help information about Docker and its commands.
  4. docker run [image]
    Create and start a container from a Docker image. Example: docker run hello-world
  5. docker ps
    List all currently running containers.
  6. docker ps -a
    List all containers (both running and stopped).
  7. docker start [container_name]
    Start a stopped container.
  8. docker stop [container_name]
    Stop a running container.
  9. docker restart [container_name]
    Restart a running container.
  10. docker rm [container_name]
    Remove a stopped container.

Docker Image Commands

  1. docker images
    List all Docker images on your system.
  2. docker pull [image_name]
    Download a Docker image from Docker Hub. Example:bashCopy codedocker pull ubuntu
  3. docker rmi [image_name]
    Remove a Docker image.
  4. docker tag [source_image] [target_image]
    Tag an image to create another image.
  5. docker build -t [image_name] .
    Build a Docker image from a Dockerfile in the current directory.
  6. docker history [image_name]
    View the history of changes made to a Docker image.

Docker Container Management

  1. docker exec -it [container_name] bash
    Access a running container’s shell.
  2. docker logs [container_name]
    View logs from a running or stopped container.
  3. docker inspect [container_name]
    View detailed information about a container in JSON format.
  4. docker commit [container_name] [new_image_name]
    Save the changes in a container as a new image.
  5. docker top [container_name]
    Display the processes running inside a container.
  6. docker diff [container_name]
    See changes made to a container’s file system.
  7. docker stats
    Display a live stream of container resource usage statistics.

Docker Networking Commands

  1. docker network ls
    List all Docker networks.
  2. docker network inspect [network_name]
    View details about a specific Docker network.
  3. docker network create [network_name]
    Create a new Docker network.
  4. docker network connect [network_name] [container_name]
    Connect a container to a network.
  5. docker network disconnect [network_name] [container_name]
    Disconnect a container from a network.

Docker Volume Commands

  1. docker volume ls
    List all Docker volumes.
  2. docker volume create [volume_name]
    Create a new Docker volume.
  3. docker volume rm [volume_name]
    Remove a Docker volume.
  4. docker volume inspect [volume_name]
    View detailed information about a volume.
  5. docker run -v [volume_name]:[container_path] [image]
    Attach a volume to a container.

Docker Image Management

  1. docker save [image_name] > [file_path]
    Save a Docker image to a tar archive.
  2. docker load < [file_path]
    Load a Docker image from a tar archive.
  3. docker export [container_name] > [file_path]
    Export a container’s file system to a tar archive.
  4. docker import [file_path] [new_image_name]
    Create a new Docker image from an exported tar archive.

Advanced Docker Commands

  1. docker prune
    Remove unused containers, networks, images, and volumes.
  2. docker container prune
    Remove all stopped containers.
  3. docker image prune
    Remove unused Docker images.
  4. docker system prune
    Remove all unused Docker data.

Additional Useful Commands

  1. docker attach [container_name]
    Attach your terminal to a running container.
  2. docker rename [old_name] [new_name]
    Rename a container.
  3. docker cp [container_name]:[source_path] [destination_path]
    Copy files or directories between a container and the local filesystem.
  4. docker pause [container_name]
    Pause all processes within a container.
  5. docker unpause [container_name]
    Unpause a paused container.
  6. docker update [container_name] [options]
    Update configuration of a container.
  7. docker wait [container_name]
    Block until a container stops and then print its exit code.
  8. docker events
    Get real-time events from the Docker daemon.
  9. docker search [term]
    Search for Docker images on Docker Hub.

Conclusion

Mastering these Docker commands will improve your daily container management. From basic container operations to advanced image and network configurations, these commands help optimize Docker’s functionality.

If you’re just starting with Docker, we recommend reading this guide on how to install Docker on Ubuntu or exploring our Beginner’s Guide to Kubernetes to understand how Docker integrates with other tools.

External Reference

For more in-depth Docker documentation, visit the official Docker documentation.

Ravi Chopra

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top