Installing Centreon in Docker on a Raspberry Pi 3

This time I am going to install Centreon in a Docker container. Currently, I have Pi-hole working on my Raspberry and it’s working as DHCP server and DNS. Without Docker, the installation of Centreon it could be have been quite tricky.

In order to install Centreon in Docker I followed the next steps:

  1. Create a Docker file for the installation and configuration of the container.
  2. I did a fork of a script made by Kermith72 the next one: auto_install.

As I always said, you already know that you can follow the Docker file updated in my GitHub: Dockerfile. Also I did some modifications in the Kermith72’s script since i used a Raspbian over a Debian:buster container. The following is the Installation script: centreon_central.sh

INSTALLATION

We have to create a directory called Docker in /root:

mkdir -p /root/docker
cd /root/docker

Inside of this directory we shall create the Dockerfile with the following content:

FROM debian:latest

ENV container docker
ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive

RUN echo "deb http://ftp.es.debian.org/debian/ buster main contrib non-free" >> /etc/apt/sources.list
RUN apt-get update 
    && apt-get install -y systemd git gpg wget curl 
    && apt-get clean 
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN rm -f /lib/systemd/system/multi-user.target.wants/* 
    /etc/systemd/system/*.wants/* 
    /lib/systemd/system/local-fs.target.wants/* 
    /lib/systemd/system/sockets.target.wants/*udev* 
    /lib/systemd/system/sockets.target.wants/*initctl* 
    /lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup* 
    /lib/systemd/system/systemd-update-utmp*

RUN cd /root && wget https://raw.githubusercontent.com/deividgdt/dockerpicentreon/master/centreon_central.sh
RUN chmod +x /root/centreon_central.sh

VOLUME [ "/sys/fs/cgroup" ]

CMD ["/lib/systemd/systemd"]

You can download the previous file updated from my GitHub:

wget https://raw.githubusercontent.com/deividgdt/dockerpicentreon/master/Dockerfile

Then we build the image:

[root@raspi]─[~] docker build -t centreon:0.0 .
Sending build context to Docker daemon   2.56kB
Step 1/11 : FROM debian:latest
latest: Pulling from library/debian
3182cf45068c: Pull complete
Digest: sha256:a63d0b2ecbd723da612abf0a8bdb594ee78f18f691d7dc652ac305a490c9b71a
Status: Downloaded newer image for debian:latest
 ---> 756aa643c9cd
Step 2/11 : ENV container docker
 ---> Running in a0cf5171a92e
Removing intermediate container a0cf5171a92e
------------------------------[OUTPUT TRUNCATE]--------------------------

Then we check if our image has been created:

[root@raspi]─[~] docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centreon            0.0                 e940169369c9        52 minutes ago      241MB
debian              latest              756aa643c9cd        10 days ago         92.8MB

Once the base image is built, we shall run the container with the volume: /sys/fs/cgroup that will provide us access to the control groups. Moreover we shall pass the parameter –privileged in order to let the container use the Kernel’s functions, basically to use systemd.

docker run -d --name centreon --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro centreon:0.0

If we check our container it should be running with the command: «/lib/systemd/systemd».

Now we shall execute a bash terminal:

docker exec -it centreon bash

And just execute the script central_centreon.sh that is inside of /root/:

/root/centreon_central.sh

The script will execute 12 steps, all of them must be finished correctly. When the script ends you must see something like this:

Once it’s finished we go out of the container and do a commit in order to turn the container into a new image. This process could take so long, in my case it took twelve minutes:

To commit we shall use the CONTAINER_ID and its TAG:

docker commit $(docker ps --filter=name=centreon --format "{{.ID}}") centreon:1.0

Remember that we have the container centreon:0.0 running, so we need to stop it:

docker stop centreon

Now we are going to run the new container using the following parameters:

  • -d –> We run the container as a daemon.
  • –name –> The name of the container.
  • –privileged –> We let the container use the Kernel’s functions, basically to get access to systemd.
  • -p 8080:80 –> We forward the port 8080 of our Rasp to the port 80 of the container.
  • -p 3306:3360 –> We forward the port 3306 of our Rasp to the port 3306 of the container
  • -v /sys/fs/cgroup:/sys/fs/cgroup:ro –> We mount this volume in order to get access to the control groups. Mandatory to use systemd.
docker run -d --name centreon1 --privileged -p 8080:80 -p 3306:3306 -v /sys/fs/cgroup:/sys/fs/cgroup:ro centreon:1.0

If we want to access to the container using SSH we should forward some external port to the 22 port in the container, for example, in the following command we forward the port 10022 of our Rasp to the port 22 of the container:

docker run -d --name centreon1 --privileged -p 8080:80 -p 3306:3306 -p 10022:22 -v /sys/fs/cgroup:/sys/fs/cgroup:ro centreon:1.0

Now we need to complete configuration of Centreon, so go to: http://raspberry_ip:8080/centreon

The configuration is really simply and you do not have touch nothing, unless you want to customize some directory. Apart of this, the following information will be requested:

  • Centreon admin password.
  • MySQL root password.
  • Password of the centreon user who owns the bbdd centreon_storage

Once the configuration is finished you should see the following:

And finally the message that confirm us that Centreon has been installed properly:

I have checked the memory RAM, CPU and Disk space usage and to be honest is almost imperceptible:

This configuration use at least 3 GB of disk space, 200 MB of RAM, and apart of this as you can see in the previous image the load average is really low:

TROUBLESHOOTING

If you have any problem reaching the website, the most probably is that php7.3-fpm is not creating the folder to store the Unix socket, so in order to fix it, just follow the next steps:

First, make sure that this is your issue, checking the php7.3-fpm service status:

root@cc8949b0b466:/run# systemctl status php7.3-fpm
* php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-08-15 19:33:54 UTC; 1min 18s ago
     Docs: man:php-fpm7.3(8)
  Process: 944 ExecStart=/usr/sbin/php-fpm7.3 --nodaemonize --fpm-config /etc/php/7.3/fpm/php-fpm.conf (code=exited, status=78)
 Main PID: 944 (code=exited, status=78)

Aug 15 19:33:54 cc8949b0b466 systemd[1]: Starting The PHP 7.3 FastCGI Process Manager...
Aug 15 19:33:54 cc8949b0b466 php-fpm7.3[944]: [15-Aug-2020 19:33:54] ERROR: unable to bind listening socket for address '/run/php/php7.3-fpm.sock': No such file or directory (2)

Then just create the folder and restart the service php7.3-fpm:

root@cc8949b0b466:/run# mkdir -p /run/php && systemctl restart php7.3-fpm

RESUME

mkdir -p /root/docker
cd /root/docker
wget https://raw.githubusercontent.com/deividgdt/dockerpicentreon/master/Dockerfile
docker build -t centreon:0.0 .
docker run -d --name centreon --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro centreon:0.0
docker exec -it centreon bash
 /root/centreon_central.sh
 exit
docker commit $ID_CENTREON00 centreon:1.0
docker stop centreon
docker run -d --name centreon1 --privileged -p 8080:80 -p 3306:3306 -p 10022:22 -v /sys/fs/cgroup:/sys/fs/cgroup:ro centreon:1.0
Ir a http://$RASP_IPADDRESS:8080/centreon y configurar Centreon.

If you have any issue with the installation, do not hesitate to lave a comment below. I will try to help you.

5 comentarios sobre “Installing Centreon in Docker on a Raspberry Pi 3

  1. I have a problem, it throws an error when I start to assemble the script in the mariadb part and in the perl and ssh connectors. Did it ever happen to you? it could be a permission problem

  2. Hi Deivid,

    I followed all the steps that were mentioned in the blog but it is not working for me.

    I am facing issue at «No we need to complete configuration of Centreon, so go to: http: // raspberry_ip: 8080 / centreon»

    Web page is not coming for me.

    Kindly help

    1. Hi there Ninad,

      The problem is that php7.3-fpm is not working, for some reason it’s no creating the directory /var/run/php to store the unix socket. So, you need to follow the next steps in order to fix it:
      $ docker exec -it centreon1 bash
      centreon # mkdir -p /var/run/php
      centreon # systemctl restart php7.3-fpm

      Now you can go to http://RASPBERRYPI_IP:8080/centreon

      I will add this information to the post.

      Thanks!

Deja una respuesta

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Salir /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Salir /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s