Skip to content

Instantly share code, notes, and snippets.

@dejanu
Last active December 3, 2024 12:26
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 support 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}}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment