dockertraefik

healthcheck for the image traefik:1.6


How can I build a docker-compose file with the healthcheck for the image traefik:1.6 to validate if the container is healthy? Remarks: The image does not have cmd-shell access. I would not like to change the version of the image.


Solution

  • You can use the healthcheck command.

    You have to activate the ping.

    After you have to define a healthcheck section in your docker-compose file.

    example:

    proxy:
      image: traefik:1.6
      command: --api --docker --ping
      ports:
        - "80:80"
        - "8080:8080"
      # ...
      healthcheck:
        test: ["CMD", "traefik" ,"healthcheck"]
        interval: 30s
        timeout: 3s
        retries: 30