A
Aura Dev

Docker Cheatsheet

Common Docker commands and usage.

Containers

docker ps

List running containers

docker ps -a

List all containers (including stopped)

docker start <container>

Start a stopped container

docker stop <container>

Stop a running container

docker rm <container>

Remove a container

docker rm -f <container>

Force remove a running container

docker logs <container>

Fetch the logs of a container

docker exec -it <container> bash

Run a command in a running container

Images

docker images

List local images

docker pull <image>

Pull an image from a registry

docker build -t <name> .

Build an image from a Dockerfile

docker rmi <image>

Remove an image

docker tag <image> <new-image>

Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

docker push <image>

Push an image or a repository to a registry

Volumes

docker volume ls

List volumes

docker volume create <name>

Create a volume

docker volume rm <name>

Remove a volume

docker volume inspect <name>

Display detailed information on one or more volumes

Networks

docker network ls

List networks

docker network create <name>

Create a network

docker network rm <name>

Remove a network

docker network connect <net> <container>

Connect a container to a network

docker network disconnect <net> <container>

Disconnect a container from a network

Docker Compose

docker-compose up

Create and start containers

docker-compose up -d

Start containers in the background

docker-compose down

Stop and remove containers, networks

docker-compose ps

List containers

docker-compose logs

View output from containers

docker-compose build

Build or rebuild services

System

docker info

Display system-wide information

docker version

Show the Docker version information

docker system prune

Remove unused data

docker system prune -a

Remove all unused images not just dangling ones

What is Docker?

Docker is a platform that uses OS-level virtualization to deliver software in standardized packages called containers.

This cheatsheet covers the most common Docker CLI commands for building images, running containers, and managing volumes and networks.