Docker Commands

Table of Contents

Basic listing and status

  • docker ps — running containers
  • docker ps -a — all containers (including stopped)
  • docker stats — live CPU/memory/network/IO usage
  • docker stats --no-stream — one-shot snapshot

Detailed inspection

  • docker inspect <container> — full JSON config, state, network, mounts
  • docker inspect -f '' <container> — extract a single field via Go template
  • docker inspect -f '' <container> — get IP
  • docker inspect -f '' <container> — environment variables
  • docker inspect -f '' <container> — host PID of main process

Logs

  • docker logs <container> — stdout/stderr
  • docker logs -f <container> — follow
  • docker logs --tail 100 <container> — last N lines
  • docker logs --since 10m <container> — time-filtered

Processes and runtime

  • docker top <container> — running processes inside the container
  • docker port <container> — port mappings
  • docker diff <container> — filesystem changes vs image
  • docker exec -it <container> sh — interactive shell (or bash)
  • docker exec <container> ps aux — run a command without a shell session

Resource and filesystem

  • docker cp <container>:/path ./local — copy files out for inspection
  • docker inspect -f '' <container> — memory limit
  • docker inspect -f '->\n' <container> — mounts

Events and history

  • docker events --filter container=<container> — real-time lifecycle events
  • docker container inspect --size <container> — include writable-layer size (SizeRw, SizeRootFs)

Image provenance

  • docker inspect -f '' <container> — image ID
  • docker history <image> — layer history

This site uses Just the Docs, a documentation theme for Jekyll.