Last active
December 2, 2020 16:44
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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