# How to do \`healthcheck\` on traefik itself?

**URL:** <https://community.traefik.io/t/how-to-do-healthcheck-on-traefik-itself/1462>\
**Category:** Traefik v2\
**Tags:** docker-swarm\
**Created:** [September 5, 2019, 3:57am UTC](https://community.traefik.io/t/how-to-do-healthcheck-on-traefik-itself/1462 "2019-09-05T03:57:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![trajano](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/trajano/32/247_2.png) [@trajano](https://community.traefik.io/u/trajano)\
**Post date:** [September 5, 2019, 3:57am UTC](https://community.traefik.io/t/how-to-do-healthcheck-on-traefik-itself/1462/1 "2019-09-05T03:57:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [September 5, 2019, 9:31am UTC](https://community.traefik.io/t/how-to-do-healthcheck-on-traefik-itself/1462/2 "2019-09-05T09:31:28Z")

</div>

- [https://docs.traefik.io/v2.0/operations/cli/#healthcheck](https://docs.traefik.io/v2.0/operations/cli/#healthcheck)
- [https://docs.traefik.io/v1.7/basics/#command-healthcheck](https://docs.traefik.io/v1.7/basics/#command-healthcheck)

---

<div class="post-metadata">

**Author:** ![trajano](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/trajano/32/247_2.png) [@trajano](https://community.traefik.io/u/trajano)\
**Post date:** [September 5, 2019, 11:02am UTC](https://community.traefik.io/t/how-to-do-healthcheck-on-traefik-itself/1462/3 "2019-09-05T11:02:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [September 5, 2019, 11:07am UTC](https://community.traefik.io/t/how-to-do-healthcheck-on-traefik-itself/1462/4 "2019-09-05T11:07:53Z")

</div>

Tthe command `healtcheck` is a standalone command:

```auto
docker run traefik:v2.0.0-rc2 healthcheck
docker run traefik:v1.7.14 healthcheck

```

and the binary is not in the PATH:

```auto
docker exec f1dda0094a5f ./traefik healthcheck

```

- [https://docs.traefik.io/v2.0/operations/cli/#healthcheck](https://docs.traefik.io/v2.0/operations/cli/#healthcheck)
- [https://docs.traefik.io/v1.7/basics/#command-healthcheck](https://docs.traefik.io/v1.7/basics/#command-healthcheck)

---

<div class="post-metadata">

**Author:** ![trajano](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/trajano/32/247_2.png) [@trajano](https://community.traefik.io/u/trajano)\
**Post date:** [September 5, 2019, 11:17am UTC](https://community.traefik.io/t/how-to-do-healthcheck-on-traefik-itself/1462/5 "2019-09-05T11:17:40Z")

</div>

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.

```auto
    healthcheck:
      test: ./traefik healtcheck --ping 

```

However, when adding that, it terminates traefik.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/1X/1c71af6b92998a78e73bb49fa3143eb838d4ef07.png)

---

<div class="post-metadata">

**Author:** ![trajano](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/trajano/32/247_2.png) [@trajano](https://community.traefik.io/u/trajano)\
**Post date:** [September 27, 2019, 1:35am UTC](https://community.traefik.io/t/how-to-do-healthcheck-on-traefik-itself/1462/6 "2019-09-27T01:35:45Z")

</div>

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](https://community.containo.us/t/trajano-base-docker-swarm-stacks/1899)

---

<div class="post-metadata">

**Author:** ![PackElend](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/packelend/32/1178_2.png) [@PackElend](https://community.traefik.io/u/PackElend)\
**Post date:** [December 31, 2019, 3:20pm UTC](https://community.traefik.io/t/how-to-do-healthcheck-on-traefik-itself/1462/7 "2019-12-31T15:20:36Z")

</div>

I fully agree that the docs could be improved. The current docs ([of CLI](https://docs.traefik.io/operations/cli/)) made me interpret it as a command available on the host.

```auto
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

```auto
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](https://community.containo.us/t/strange-healthcheck-behaviour/2957) 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](https://docs.docker.com/engine/reference/commandline/exec/) for more details on the flags.
