Code & computing / QUICK REFERENCE

Docker essentials

Inspect containers, images, logs, networks and Compose projects before changing a running environment.

32 entries

Inspect the running environment

Client and server versions
docker version

The server section requires daemon access. [2][1]

Engine information
docker info

Can expose local infrastructure details. [2][1]

Running containers
docker ps

Lists containers currently running. [2][1]

All containers
docker ps -a

Includes stopped containers. [2][1]

Readable container names
docker ps --format '{{.Names}}'

Uses a Go template for selected output. [2][1]

Container details
docker inspect web

Includes configuration that may contain secrets. [2][1]

Live resource usage
docker stats

Streams CPU/memory/network counters. [2][1]

One resource sample
docker stats --no-stream

Returns one measurement and exits. [2][1]

Logs and troubleshooting

Recent log lines
docker logs --tail 100 web

Requires a logging driver supporting retrieval. [2][1]

Follow logs
docker logs -f web

Ctrl+c stops following, not the container. [2][1]

Logs since a duration
docker logs --since 10m web

Retrieves recent output using the container clock context. [2][1]

Processes in a container
docker top web

Inspects process listings from the host. [2][1]

Port mappings
docker port web

Shows published host/container port relationships. [2][1]

Container filesystem changes
docker diff web

Lists changes relative to the container image. [2][1]

Inspect health status
docker inspect --format '{{json .State.Health}}' web

Health data exists only with a configured health check. [2][1]

Execute a diagnostic command
docker exec web pwd

Runs a new process inside an existing running container. [2][1]

Images, networks and volumes

List local images
docker image ls

Lists locally available image references. [3][1]

Inspect an image
docker image inspect app:dev

Shows image configuration and metadata. [3][1]

Image build history
docker image history app:dev

Inspect before sharing; historical commands may reveal sensitive details. [3][1]

Build a development image
docker build -t app:dev .

Uses the current directory as build context. [3][1]

Engine disk usage
docker system df

Reports images, containers and volumes without pruning. [3][1]

List networks
docker network ls

Shows available Docker networks. [3][1]

Inspect a network
docker network inspect bridge

Displays network configuration and attached containers. [3][1]

List volumes
docker volume ls

Lists managed volumes without deleting their data. [3][1]

Compose project workflow

Validate Compose configuration
docker compose config -q

Checks validity without printing expanded secrets. [4][1]

Show Compose services
docker compose config --services

Lists service names in the resolved project. [4][1]

Project container status
docker compose ps

Restricts the view to this Compose project. [4][1]

Project logs
docker compose logs --tail 100

Reads logs across project services. [4][1]

Follow one service
docker compose logs -f web

Follows the named Compose service. [4][1]

Build project images
docker compose build

Builds services with build definitions. [4][1]

Start in background
docker compose up -d

Creates or updates resources; inspect the target project first. [4][1]

Read service working directory
docker compose exec web pwd

Executes a process in the running service container. [4][1]

Reserved placement, separate from reference controls. No ad network is active.

Updated Docker CLI / docker compose v2

Sources

  1. Docker CLI reference ↗
  2. Container command reference ↗
  3. Image command reference ↗
  4. Docker Compose CLI ↗