DKR

Docker Cheatsheet

The docker and docker compose commands used daily for building, running, and managing containers.

Images

docker build -t name .

Build an image from a Dockerfile

docker images

List local images

docker rmi <image>

Remove an image

docker pull <image>

Download an image from a registry

Containers

docker run -p 3000:3000 image

Run a container, mapping a port

docker run -d image

Run a container in the background

docker ps

List running containers

docker ps -a

List all containers, including stopped

docker stop <id>

Stop a running container

docker exec -it <id> bash

Open a shell inside a running container

docker logs <id>

View a container's logs

Docker Compose

docker compose up

Start all services

docker compose up -d

Start all services in the background

docker compose down

Stop and remove containers/networks

docker compose logs -f

Follow logs from all services