Public | Automated Build

Last pushed: 7 months ago
Short Description
Cacti Server with HTTP2/support and SSL termination
Full Description

###Cacti Server (CentOS7 + Supervisor)







Docker Image with Cacti server using million12/nginx-php docker image as base. (HTTP2 and HAProxy SSL termination ready.)
Image is using external datbase and it's build on PHP 7.0.

Database deployment

To be able to connect to database we would need one to be running first. Easiest way to do that is to use another docker image. For this purpose we will use our million12/mariadb image as our database.

For more information about million12/MariaDB see our documentation.

Example:

docker run \
-d \
--name cacti-db \
-p 3306:3306 \
--env="MARIADB_USER=cactiuser" \
--env="MARIADB_PASS=my_password" \
million12/mariadb

Remember to use the same credentials when deploying cacti image.

Environmental Variable

In this Image you can use environmental variables to connect into external MySQL/MariaDB database.

DB_USER = database user
DB_PASS = database password
DB_ADDRESS = database address (either ip or domain-name)
TIMEZONE = timezone

HTTP/2 Support

Container is built with http/2 support and by default it listens on port 443.
Make sure you open it on docker run.
Port 81 is used by default for load balancing (HAProxy) ssl termination.

Cacti Deployment

Now when we have our database running we can deploy cacti image with appropriate environmental variables set.

Example:

docker run \
-d \
--name cacti \
-p 80:80 \
-p 443:443 \
--env="DB_ADDRESS=database_ip" \
--env="DB_USER=cactiuser" \
--env="DB_PASS=my_password" \
polinux/cacti

Access Cacti web interface

To log in into cacti for the first time use credentials admin:admin. System will ask you to change those when logged in for the firts time.

Access web interface under

dockerhost.ip/install

Follow the on screen instructions.

Author

Author: Przemyslaw Ozgo (linux@ozgo.info)


Docker Pull Command
Owner
polinux
Source Repository

Comments (6)
dolon
2 months ago

I have exactly the same issue:
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /data/www/cacti/lib/database.php on line 251

alxcord
4 months ago

Hi, I linked my current database, I receive the error "
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) in /data/www/cacti/lib/database.php on line 250" on first access.

Before that I checked on db and there is no tables created.

I tried creating the database before and not creating, same result.

CREATE USER cacti
IDENTIFIED BY '<pass>';
create database cacti;
grant ALL on . to cacti;
FLUSH PRIVILEGES;

My compose:

c_mariadb:
image: mariadb:latest
hostname: c_mariadb
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes:

  - "/samba/data/c_mariadb/conf.d:/etc/mysql/conf.d:rw"
  - "/samba/data/c_mariadb/data:/var/lib/mysql:rw"
  - "/samba/data/c_mariadb/backup:/var/backup:rw"
environment:
  - "MYSQL_ROOT_PASSWORD=<pass>"
  - "MYSQL_USER=alexcord"
  - "MYSQL_PASSWORD=<pass>>"
ports:
  - "3306:3306"

c_cacti:
image: polinux/cacti
hostname: c_cacti
links:

  - c_mariadb
depends_on:
  - c_mariadb
volumes:
  - "/samba/cacti/backups:/var/backups:rw"
environment:
  - "DB_ADDRESS=c_mariadb" 
  - "DB_USER=cacti" 
  - "DB_PASS=<<pass>>" 
  - "TIMEZONE=America/Sao_Paulo" 
ports:
  - "8161:80"
  - "44361:443"
restart: always  
twhtanghk
a year ago

I experienced the same database connection problem reported by jk04. For your info, the following patch for '/config/bootstrap.sh' is to

  1. wait for mysql server completely started before starting cacti
  2. remove $url_path in config.php to fallback the context path to '/cacti/'

2a3,4

sleep 10

19a22,34

ln -s /opt/remi/php70/root/usr/bin/php /usr/bin

cat <<EOF >/data/www/cacti/include/config.php
<?php
\$database_type = "mysql";
\$database_default = "cacti";
\$database_hostname = "cacti_mysql";
\$database_username = "user";
\$database_password = "pass";
\$database_port = "3306";
\$database_ssl = false;
EOF

polinux
a year ago

@jk04 the best way to do that is to link those two images. See docker-cloud.yml in my repo for details.

jk04
2 years ago

Hi,

I have followed you instructions but have come across database connection problems. Here's what I do:

STEP 1:
docker run -d --name cacti-db -p 3306:3306 --env="MARIADB_USER=admin" --env="MARIADB_PASS=admin123" million12/mariadb

This step finishes without errors and I am able to manually connect to the database servre from docker host.

STEP 2:
docker run --name cacti -p 80:80 --env="DB_ADDRESS=127.0.0.1" --env="DB_USER=admin" --env="DB_PASS=admin123" polinux/cacti
mysqlshow: Can't connect to MySQL server on '127.0.0.1' (111)
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)

I am running docker 1.6.2 on a Debian 8.

Regards,
jk04

polinux
3 years ago

Image updated with external database implementation. Enjoy! :)