Problems starting apache2 in Docker container

CMK version: 2.3.0p42 RAW
OS version: Docker 29.2.1, Ubuntu Server 25.10

I’m trying to transition my checkmk installation from an older linux machine to a more modern virtualized environment using Docker.

I’ve largely succeeded except for two things:

  1. When I perform a “docker compose up”, apache2 will not start. I have to get into the container shell and invoke “omd update-apache-config”, then “service apache2 start”.
  2. When I perform a container restart after this, I have to get into the container shell and invoke “service apache2 start”.

How can I get the update-apache-config to be persistent?

How can I get apache2 to start reliably when the container starts?

Docker compose file follows (site name is “abc”). Note that I also had to work-around the problem of avoiding an underscore in the time zone name.

services:

  checkmk:

    image: checkmk/check-mk-raw:2.3.0p42

    container_name: checkmk_server

    ports:

      - 8081:80

      - 444:443

      - 8000:8000

      - 6556:6556

      - 161:161

      - 162:162

    volumes:

      - ./checkmk_data:/omd/sites

    tmpfs:

      - /opt/omd/sites/abc/tmp:uid=1000,gid=1000

    environment:

      - CMK_SITE_ID=abc

      - TZ=US/Eastern

    restart: unless-stopped


volumes:

  checkmk_data:

    driver: local

I’ve sorted out the persistence of the omd update-apache-config command. I had to:

  • Define a volume for the /etc/apache2 directory
  • Start the container for the first time
  • Run omd update-apache-config

After that, the apache2 configuration remains persistent across container restarts or updates.

This ought to be documented somewhere and shown in examples. I’ve included my current Docker Compose file below.

I am still searching for a solution to the problem of the apache2 service not starting when the container starts. Any help with this problem would be most appreciated.

services:
  checkmk:
    image: checkmk/check-mk-raw:2.3.0p42
    container_name: checkmk_server
    ports:
      - 8081:80
      - 444:443
      - 8000:8000
      - 6556:6556
      - 161:161
      - 162:162
    volumes:
      - ./checkmk_data:/omd/sites
      - ./apache_data:/etc/apache2
    tmpfs:
      - /opt/omd/sites/abc/tmp:uid=1000,gid=1000
    environment:
      - CMK_SITE_ID=abc
      - TZ=US/Eastern
    restart: unless-stopped

volumes:
  checkmk_data:
    driver: local
  apache_data:
    driver: local

Inside the CheckMK container there should be no running system Apache. Only the site Apache.

The container setup documentation will show how a working compose file should look like.

You will have only two ports that are really needed 8000 for the TLS registration and some other port 8080 (from the documentation) to the internal site Apache port 5000.

Hi Andreas,

Thank you for the reply!

Yes, I understand. I am referring to the apache instance that runs inside the container. Or perhaps I should say, it runs inside the container only after I access the container shell and start it manually.

Again, yes, I used that as my initial model for my compose file, so I am familiar.

I have remote agents that need 6556, and I have other hosts with SNMP that need to be monitored so I need 161 and 162.

Somewhat more subtle is that something in the copy of my site that I backed up from the stand-alone Checkmk instance to the Docker host machine is forcing port 80 instead of 5000. If I load up a completely blank Docker instance of Checkmk with a fresh, empty site, it does utilize 5000, but not with the copy of my existing site. At any rate, that doesn’t really matter.

Back to focusing on the problem: apache (inside the container) won’t start when the container starts. I can only guess that it is an order of operations problem, that something in the container is not ready when apache goes to start. I should add this happens with a completely new Checkmk Docker instance with a default and empty “cmk” site and the default ports. Thus it does not appear to have anything to do with my site database that I brought over.

I’m not certain what internal container logs to look at. Any suggestions?

No - if you do a “service apache2 start” you start a system Apache and this should be not the case.

No you don’t need to open these ports on your container. You reach the devices on these ports but no one access your container on these ports.

That matters, as it means your backup is not working correctly or the old standalone site has some misconfigurations.

That is correct it should not start. Only the Apache inside the site. This is not the Apache inside the container.

If you spin-up an empty container what is the status of your site after this?

You can go into your container to the site folder and there inside /omd/sites//var/log you should find all relevant log files.

Hi Andreas,

My apologies. Your post got me thinking, and reading, and even though I’ve been running checkmk a long time, I had no idea that apache was part of OMD! :exploding_head:

I’ve updated my site configuration, which did deviate from the defaults. It now reads:

OMD[abc]:~$ omd config show
ADMIN_MAIL: 
AGENT_RECEIVER: on
AGENT_RECEIVER_PORT: 8000
APACHE_MODE: own
APACHE_TCP_ADDR: 127.0.0.1
APACHE_TCP_PORT: 5000
AUTOSTART: on
CORE: nagios
LIVESTATUS_TCP: off
MKEVENTD: on
MKEVENTD_SNMPTRAP: off
MKEVENTD_SYSLOG: off
MKEVENTD_SYSLOG_TCP: off
MULTISITE_AUTHORISATION: on
MULTISITE_COOKIE_AUTH: on
PNP4NAGIOS: on
TMPFS: on

I’ve also updated my compose file:

services:
  checkmk:
    image: checkmk/check-mk-raw:2.3.0p42
    container_name: checkmk_server
    ports:
      - 5000:5000
      - 8000:8000
    volumes:
      - ./checkmk_data:/omd/sites
    tmpfs:
      - /opt/omd/sites/abc/tmp:uid=1000,gid=1000
    environment:
      - CMK_SITE_ID=abc
      - TZ=US/Eastern
    restart: unless-stopped

volumes:
  checkmk_data:
    driver: local

I can see no errors in the apache logs in /omd.

However, the site does not load at http://localhost:5000/abc/

same problem ??

Migrating from a regular Linux host to a Docker host: insanely difficult, or did I do it the hard way? - General - Checkmk Forum

1 Like

Yes it is, Bernd. Andreas got me charging down the right path on my own.

Cheers!