I’m trying to get the health state of a docker container with the inspect command. The following commands work on their own:
docker inspect --format "{{slice .Id 0 12}}" [id]
docker inspect --format "{{if .State.Health}}{{.State.Health.Status}}{{else}}undefined{{end}}" [id]
However, when I try to join the two commands it throws an error:
docker inspect --format "{{slice .Id 0 12}} {{if .State.Health}}{{.State.Health.Status}}{{else}}undefined{{end}}"
template parsing error: template: :1:30: executing “” at <.State.Health>: map has no entry for key “Health”