Running checkmk with docker-compose behind Traefik

“Checkmk provides powerful monitoring of networks, servers, clouds, containers and applications. Fast. Effective.”

That said, I’m exploring checkmk with hopes, that it’s easier to setup than a stack of Prometheus, Cadvisor, Grafana, and Loki, and that it’s more powerful than Uptime Kuma.

The goal is to run checkmk from a docker-compose.ymland behind a Traefik reverse proxy.

The Traefik setup aims to serve its applications on a local network only. Therefore any ssl configuration is omitted. The docker-compose.yml is pretty straight forward:

#---
version: '3.9'
services:
traefik:
image: traefik:2.6
container_name: traefik
restart: always
command:
- "--log.level=WARN"
- "--accesslog=false"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8081:8080"
networks:
- proxy
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
proxy:
external: true

The checkmk documentation focuses on native binaries and Docker. However a compose-file can be derived from the docker run command:

#---
version: "3.9"
services:
checkmk:
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.routers.checkmk.entrypoints=web"
- "traefik.http.routers.checkmk.rule=PathPrefix(`/cmk`) || PathPrefix(`/cmk/`)"
- "traefik.http.services.checkmk.loadbalancer.server.port=5000"
image: checkmk/check-mk-raw:2.0.0-latest
container_name: checkmk
restart: unless-stopped
environment:
- TZ=Europe/Berlin
volumes:
- /etc/localtime:/etc/localtime:ro
- ./sites:/omd/sites
tmpfs:
- /opt/omd/sites/cmk/tmp:uid=1000,gid=1000
networks:
- proxy
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
proxy:
external: true

Once Traefik and checkmk spin up, the server will be available at http://<server>/cmk. Its initial credentials will be written to the log on startup.

The Getting started guide outlines who to add hosts to the monitoring. It’s tricky to read, but it will work. Keep in mind that localhost will refer to the container and not the machine running the container.

To monitor this machine, an agent needs to be installed. This agent can be added to checkmk host by using the hostname host.docker.internal.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store