In 1.7 I am able to do the following:
healthcheck:
test: wget -q --spider http://localhost:8080/ping
But in 2.0 I can't find the command to run.
In 1.7 I am able to do the following:
healthcheck:
test: wget -q --spider http://localhost:8080/ping
But in 2.0 I can't find the command to run.
I saw that before. when I run that command using docker exec [containerid] traefik healtcheck
OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: "traefik": executable file not found in $PATH": unknown
In addition it never returns healthy.
Neither does healthcheck
alone
OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: "healtcheck": executable file not found in $PATH": unknown
Tthe command healtcheck
is a standalone command:
docker run traefik:v2.0.0-rc2 healthcheck
docker run traefik:v1.7.14 healthcheck
and the binary is not in the PATH:
docker exec f1dda0094a5f ./traefik healthcheck
The documentation left out the ./
and it needs the --ping
to be specified
docker exec 48d286711eae ./traefik healthcheck --ping
time="2019-09-05T11:13:31Z" level=info msg="Configuration loaded from flags."
OK: http://:8080/ping
also healthcheck ignores any attempts to disable logging, so --log=false
or --log.level=ERROR
still displays the message
So the final solution you would think at the moment is the following in the docker-compose.yml file.
healthcheck:
test: ./traefik healtcheck --ping
However, when adding that, it terminates traefik.
This appears to be working in the GA release using the following
healthcheck:
test: traefik healthcheck --ping
I have incorporated it in Trajano base Docker swarm stacks
I fully agree that the docs could be improved. The current docs (of CLI) made me interpret it as a command available on the host.
root@Ubuntu18:~# traefik healthcheck --ping
traefik: command not found
so reading this here eventually enlightened me, so I did
docker exec [container name] traefik healtcheck --ping
what results in
root@Ubuntu18:~# docker exec -it traefik traefik healthcheck --ping
INFO[0000] Configuration loaded from flags.
Bad healthcheck status: 404 Not Found
I found a discussion on this result in Strange healthcheck behaviour but I still don't get it.
I used the -t flag to make the output to look a bit prettier. See docker exec | Docker Documentation for more details on the flags.