Docker Cheat Sheets

Image Management

Pull an image from a registry:

  docker pull ubuntu

Build an image from a Dockerfile:

  docker build -t my_image .

List images:

  docker images

Remove an image:

  docker rmi my_image

Remove all images:

  docker rmi $(docker images -q)

Container Lifecycle

Run a new container:

  docker run -d --name my_container nginx

Start a stopped container:

  docker start my_container

Stop a running container:

  docker stop my_container

Remove a container:

  docker rm my_container

Remove all containers:

  docker rm $(docker ps -a -q)

Container Monitoring

List containers:

  docker ps

Fetch the logs of a container:

  docker logs my_container

Networking

List networks:

  docker network ls

Create a new network:

  docker network create my_network

Volumes

List volumes:

  docker volume ls

Create a volume:

  docker volume create my_volume

If you need more examples or have any other questions, feel free to ask!

Last updated