List of Docker CLI Commands

    To execute Docker CLI commands, you must first install Docker on your system based on your operating system. Refer to the Installation section for detailed setup instructions specific to macOS, Windows, and Linux.

    General Commands#

    1. Check docker version: docker --version
    2. Start the docker daemon: docker -d
    3. Get help with Docker. Can also use --help on all subcommands: docker --help
    4. Display system-wide information: docker info

    Images#

    1. List local images: docker images
    2. Pull an image from Docker Hub: docker pull <image_name>
    3. Delete an image: docker rmi <image_name>
    4. Remove all unused images: docker image prune
    5. Build an image from Dockerfile: docker build -t <image_name>
    6. Build an image from Dockerfile without the cache: docker build -t <image_name> . -no-cache

    Container#

    1. Create and run a container from an image, with a custom name: docker run --name <container_name> <image_name>
    2. Run a container with and publish a container’s port(s) to the host: docker run -p <host_port>:<container_port> <image_name>
    3. Run a container in the background: docker run -d <image_name>
    4. Start or stop an existing container: docker start|stop <container_name> (or <container-id>)
    5. Remove a stopped container: docker rm <container_name>
    6. Open a shell inside a running container: docker exec -it <container_name> sh
    7. Fetch and follow the logs of a container: docker logs -f <container_name>
    8. To inspect a running container: docker inspect <container_name> (or <container_id>)
    9. To list currently running containers: docker ps
    10. List all docker containers (running and stopped): docker ps --all or docker ps -a
    11. View resource usage stats: docker container stats
    12. Manage Persistent Storage: docker run -v [Source]:[Destination]:[Mode] / -mount type=[type],source=[src],target=[dst]
      • [Source]: The location on your Host machine (Name of volume or absolute path).
      • [Destination]: The absolute path inside the container.
      • [Mode]: Optional permissions, like ro (read-only) or rw (read-write).
      •  
      • type: Either volume (Docker managed) or bind (Direct path).
      • source: The volume name or host directory.
      • target: The destination path inside the container.

    Example: 

    docker run -d --name db_container -v postgres_data:/var/lib/postgresql/data postgres

    docker run -d --name app_dev --mount type=bind,source=$(pwd)/src,target=/app/src node:latest

    Docker Hub#

    • Login into Docker: docker login -u <username>
    • Publish an image to Docker Hub: docker push <username>/<image_name>
    • Search Hub for an image: docker search <image_name>

    Conclusion#

    Docker CLI commands provide complete control over images, containers, and registries directly from the terminal. By mastering these essential commands, developers can efficiently build, run, manage, and distribute containerized applications across different environments with precision and speed.

    Want to Master Spring Boot and Land Your Dream Job?

    Struggling with coding interviews? Learn Data Structures & Algorithms (DSA) with our expert-led course. Build strong problem-solving skills, write optimized code, and crack top tech interviews with ease

    Learn more

    Last updated on Mar 17, 2026

    Was it helpful?

    Subscribe to our newsletter

    Read articles from Coding Shuttle directly inside your inbox. Subscribe to the newsletter, and don't miss out.