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:

Remove all containers:

Container Monitoring

List containers:

Fetch the logs of a container:

Networking

List networks:

Create a new network:

Volumes

List volumes:

Create a volume:

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

Last updated