Skip to content

Instantly share code, notes, and snippets.

@dejanu
Last active March 11, 2025 13:46
Show Gist options
  • Save dejanu/12a44a086d9eed02f8770281d12de925 to your computer and use it in GitHub Desktop.
Save dejanu/12a44a086d9eed02f8770281d12de925 to your computer and use it in GitHub Desktop.
Docker: Display system-wide information and Go templates to manipulate the output format
  • Search official images for desired : docker search --format "table {{.Name}}\t{{.StarCount}}\t{{.IsOfficial}}" <IMAGE>

  • Output image name and tag: docker images --format '{{.Repository}} and {{.Tag}}'

  • Output image name, tag and elapsed time + timestamp since the image has been created: docker images --format "{{.Repository}}:{{.Tag}} {{.CreatedSince}} --> {{.CreatedAt}}"

  • Inspect Cmd for desired : docker inspect -f '{{.Config.Cmd}}' <IMAGE>

  • Inspect Entrypoint for desired : docker inspect -f '{{.Config.Entrypoint}} <IMAGE>'

  • Inspect attached containers to bridge network: docker inspect network bridge --format "{{json .Containers }}"

  • Inspect storage: docker info -f 'Storage drive: {{.Driver}} and storage path {{.DockerRootDir}}'

  • Inspect container runtimes: docker system info --format "{{.Runtimes}} {{.DefaultRuntime}}"

  • containers resource usage

# docker stats [OPTIONS] [CONTAINER...]
docker stats --no-stream
  • check the container runtimes
docker system info
docker system info --format "Runtimes:  {{.Runtimes}}  with default {{ .DefaultRuntime }}"
  • check root directory for Docker storage, defaults to /var/lib/docker
docker system info -f '{{ .DockerRootDir}}'
  • remove dangling/untagged images and not referenced by a container
docker rm $(docker ps -aq)
docker image prune -a
  • debug Docker with systemctl/service and journalctl
systemctl status docker
systemctl daemon-reload
systemctl start docker
service docker restart
journalctl -xeu docker.service
journalctl -u docker
  • get events
docker events --filter event=restart --since=60m
docker events --filter event=restart --since=60m > events.log 2>&1
  • show docker disk usage docker system df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment