DEV Community

Kartic Gharami
Kartic Gharami

Posted on

List of Docker Commands with Examples

Image description

Docker is a popular platform for containerization, and it comes with a variety of commands to manage containers, images, networks, and volumes. Here’s a list of some commonly used Docker commands, with examples:

Container Management:

  1. Docker run:
    -Creates and starts a container from an image.
    $ docker run -d — name my_container nginx

  2. Docker ps:
    -Lists running containers.
    $ docker ps

  3. docker ps -a:
    -Lists all containers (running and stopped).
    $ docker ps -a

  4. Docker stop:
    -Stops a running container.
    $ docker stop my_container

  5. Docker start:
    -Starts a stopped container.
    $ docker start my_container

  6. Docker restart:
    -Restarts a container.
    $ docker restart my_container

  7. Docker exec:
    — Executes a command in a running container.
    $ docker exec -it my_container bash

  8. Docker rm:
    — Removes one or more containers.
    $ docker rm my_container

Image Management:

  1. Docker images:
    — Lists all available images.
    $ docker images

  2. Docker pull:
    — Pulls an image from a registry.
    $ docker pull ubuntu:latest

  3. Docker rmi:
    — Removes one or more images.
    $ docker rmi ubuntu:latest

  4. Docker build:
    — Builds a Docker image from a Dockerfile.
    $ docker build -t custom_image:tag .

Network Management:

  1. docker network ls:
    — Lists all networks.
    $ docker network ls

  2. docker network create:
    — Creates a new network.
    $ docker network create my_network

  3. docker network connect:
    — Connects a container to a network.
    $ docker network connect my_network my_container

Volume Management:

  1. docker volume ls:
    — Lists all volumes.
    $ docker volume ls

  2. Docker volume create:
    — Creates a new volume.
    $ docker volume create my_volume

  3. Docker volume inspect:
    — Displays detailed information about a volume.
    $ docker volume inspect my_volume

These are just a few examples, and there are many more Docker commands available. You can explore the Docker documentation for more in-depth information: [Docker CLI documentation]. For additional information on coding and programming, you may also visit.

Top comments (0)