Skip to content

Instantly share code, notes, and snippets.

@pyhedgehog
Last active December 2, 2020 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyhedgehog/560d70c715c9a569ccac3efb30c491b4 to your computer and use it in GitHub Desktop.
Save pyhedgehog/560d70c715c9a569ccac3efb30c491b4 to your computer and use it in GitHub Desktop.
Sample docker command to show healthcheck log for local container of specified service
docker inspect -f '{{if .State.Health}}{{if ne (.State.Health.Log|len) 1}}{{range $l:=.State.Health.Log}}[{{$l.End}}] {{if eq $l.ExitCode 0}}{{"\x1b[32msuccess\x1b[0m"}}{{else}}{{"\x1b[31mfailed="}}{{$l.ExitCode}}{{"\x1b[0m"}}{{end}} {{$l.Output}}{{if gt ($l.Output|len) 1}}{{if le (split $l.Output "\n"|len) 1}}{{"\n"}}{{end}}{{else}}{{"<no output>\n"}}{{end}}{{end}}no healthcheck run yet. {{.State.Status}}{{end}}{{else}}no healthcheck configured. {{.State.Status}}{{end}}' `docker ps -qf label=com.docker.swarm.service.name=full_service_name`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment