Advertisement
mindthump

Formatted I/C inspect output

Aug 5th, 2020 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.52 KB | None | 0 0
  1. # details templates for docker images and containers
  2. read -r -d '' DOCKER_CONTAINER_STATUS_TEMPLATE <<'EOM'
  3. ===============================================
  4. Name:         {{.Name}}
  5. Id:           {{printf "%.12s" .Id}}
  6. Pid:          {{.State.Pid}}
  7. Image ID:     {{.Image}}
  8. Image Name:   {{.Config.Image}}
  9. Hostname:     {{.Config.Hostname}}
  10. MacAddress:   {{.NetworkSettings.MacAddress}}
  11. IPAddress:    {{.NetworkSettings.IPAddress}}
  12. Ports:        {{range $k, $v := .NetworkSettings.Ports}}{{printf "\n%14s" ""}}{{printf "%s" $k}} -> {{json $v}}{{end}}
  13. Networks:     {{range $k, $v := .NetworkSettings.Networks}}{{printf "\n%14s" ""}}{{printf "%s" $k}} -> Gateway:{{$v.Gateway}}, IPAddress:{{$v.IPAddress}}{{end}}
  14. Mounts:       {{range $k, $v := .Mounts}}{{printf "\n%14s" ""}}{{$k}} -> {{json $v}}{{end}}
  15. Status:       {{.State.Status}}
  16. Restarting:   {{.State.Restarting}}
  17. RestartCount: {{.RestartCount}}
  18. StartedAt:    {{.State.StartedAt}}
  19. FinishedAt:   {{.State.FinishedAt}}
  20. ===============================================
  21. EOM
  22.  
  23. read -r -d '' DOCKER_IMAGE_STATUS_TEMPLATE <<'EOM'
  24. ===============================================
  25. Id:           {{printf "%.12s" .Id}}
  26. RepoTags:     {{.RepoTags}}
  27. RepoDigests:  {{.RepoDigests}}
  28. Size:         {{printf "%s" .Size}}
  29. Created:      {{.Created}}
  30. ===============================================
  31. EOM
  32.  
  33. dkIinfo() {
  34.   docker image inspect "$@" --format="${DOCKER_IMAGE_STATUS_TEMPLATE}"
  35. }
  36. dkCinfo() {
  37.   docker container inspect "$@" --format="${DOCKER_CONTAINER_STATUS_TEMPLATE}"
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement