Install librenms in docker on ubuntu 18.04
Nov 26, 2019Edits:
- 2019-11-26 - Updated with some new sane defaults..
Install ubuntu 18.04 and do the latest dist-upgrade dance.
sudo apt update; sudo apt -y dist-upgrade; sudo apt autoremove
install docker
sudo apt-get remove docker docker-engine docker.io
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get install docker-ce
install docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Create user that runs librenms
sudo mkdir /opt/librenms ;\
sudo adduser librenms --disabled-password --home /opt/librenms --no-create-home --gecos '' ;\
sudo usermod -aG docker librenms ;\
sudo chown librenms:librenms /opt/librenms/ -R
install librenms docker-container
sudo su - librenms
mkdir ~/src ;\
cd ~/src ;\
git clone https://github.com/librenms/docker.git ;\
cp ~/src/docker/examples/traefik/.env ~/ ;\
cp ~/src/docker/examples/traefik/docker-compose.yml ~/ ;\
cp ~/src/docker/examples/traefik/librenms.env ~/
Edit some stuff..
Get id of librenms user
id -u librenms
1001 « This is the user ID
id -g librenms
1001 « This is group ID
Edit the the settings after your preferenses
vim .env
MYSQL_DATABASE=librenms
MYSQL_USER=librenms
MYSQL_PASSWORD=asupersecretpassword
SMTP_SERVER=smtp.example.com
SMTP_USERNAME=smtp@example.com
SMTP_PASSWORD=
TZ=Europe/Stockholm
PUID=1001
PGID=1001
vim docker-compose.yml
version: "3.5"
services:
traefik:
image: traefik:1.7-alpine
container_name: traefik
command:
- "--logLevel=INFO"
- "--defaultentrypoints=http,https"
- "--entryPoints=Name:http Address::80 Redirect.EntryPoint:https"
- "--entryPoints=Name:https Address::443 TLS"
- "--docker"
- "--docker.exposedbydefault=false"
- "--docker.domain=yourdomain.local"
- "--acme=false"
ports:
- target: 80
published: 80
protocol: tcp
- target: 443
published: 443
protocol: tcp
volumes:
- "./acme.json:/acme.json"
- "/var/run/docker.sock:/var/run/docker.sock"
- "./certs/:/certs/"
restart: always
db:
image: mariadb:10.2
container_name: librenms_db
command:
- "mysqld"
- "--sql-mode="
- "--innodb-file-per-table=1"
- "--lower-case-table-names=0"
- "--character-set-server=utf8"
- "--collation-server=utf8_unicode_ci"
volumes:
- "./db:/var/lib/mysql"
environment:
- "TZ=${TZ}"
- "PUID=${PUID}"
- "PGID=${PGID}"
- "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
- "MYSQL_DATABASE=${MYSQL_DATABASE}"
- "MYSQL_USER=${MYSQL_USER}"
- "MYSQL_PASSWORD=${MYSQL_PASSWORD}"
restart: always
memcached:
image: memcached:alpine
container_name: librenms_memcached
environment:
- "TZ=${TZ}"
- "PUID=${PUID}"
- "PGID=${PGID}"
restart: always
rrdcached:
image: crazymax/rrdcached
container_name: librenms_rrdcached
volumes:
- "./librenms/rrd:/data/db"
- "./rrd-journal:/data/journal"
environment:
- "TZ=${TZ}"
- "PUID=${PUID}"
- "PGID=${PGID}"
- "LOG_LEVEL=LOG_INFO"
- "WRITE_TIMEOUT=1800"
- "WRITE_JITTER=1800"
- "WRITE_THREADS=4"
- "FLUSH_DEAD_DATA_INTERVAL=3600"
restart: always
smtp:
image: juanluisbaptiste/postfix
container_name: librenms_smtp
volumes:
- "/etc/localtime:/etc/localtime:ro"
environment:
- "SERVER_HOSTNAME=librenms.yourdomain.local"
- "SMTP_SERVER=${SMTP_SERVER}"
- "SMTP_USERNAME=${SMTP_USERNAME}"
- "SMTP_PASSWORD=${SMTP_PASSWORD}"
restart: always
librenms:
image: librenms/librenms:latest
container_name: librenms
domainname: yourdomain.local
hostname: librenms
depends_on:
- db
- memcached
- rrdcached
- smtp
volumes:
- "./librenms:/data"
labels:
- "traefik.enable=true"
- "traefik.backend=librenms"
- "traefik.port=8000"
- "traefik.frontend.rule=Host:librenms.yourdomain.local"
environment:
- "TZ=${TZ}"
- "PUID=${PUID}"
- "PGID=${PGID}"
- "DB_HOST=db"
- "DB_NAME=${MYSQL_DATABASE}"
- "DB_USER=${MYSQL_USER}"
- "DB_PASSWORD=${MYSQL_PASSWORD}"
- "DB_TIMEOUT=60"
env_file:
- "./librenms.env"
restart: always
cron:
image: librenms/librenms:latest
container_name: librenms_cron
domainname: yourdomain.local
hostname: librenms
depends_on:
- librenms
volumes:
- "./librenms:/data"
environment:
- "TZ=${TZ}"
- "PUID=${PUID}"
- "PGID=${PGID}"
- "DB_HOST=db"
- "DB_NAME=${MYSQL_DATABASE}"
- "DB_USER=${MYSQL_USER}"
- "DB_PASSWORD=${MYSQL_PASSWORD}"
- "DB_TIMEOUT=60"
- "SIDECAR_CRON=1"
env_file:
- "./librenms.env"
restart: always
syslog-ng:
image: librenms/librenms:latest
container_name: librenms_syslog
domainname: yourdomain.local
hostname: librenms
depends_on:
- librenms
ports:
- target: 514
published: 514
protocol: tcp
- target: 514
published: 514
protocol: udp
volumes:
- "./librenms:/data"
environment:
- "TZ=${TZ}"
- "PUID=${PUID}"
- "PGID=${PGID}"
- "DB_HOST=db"
- "DB_NAME=${MYSQL_DATABASE}"
- "DB_USER=${MYSQL_USER}"
- "DB_PASSWORD=${MYSQL_PASSWORD}"
- "DB_TIMEOUT=60"
- "SIDECAR_SYSLOGNG=1"
env_file:
- "./librenms.env"
restart: always
Fix selfsigned cert and enter the correct FQDN when prompted.
mkdir ~/certs ;\
cd ~/certs ;\
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout cert.key -out cert.crt
cd ~
start the containers
docker-compose up -d
docker-compose logs -f
Browse to your fqdn of the host https://librenms.yourdomain.local and login with librenms/librenms
If your default user [librenms/librenms] dont workm ,create an admin user (my default user always go bork)
docker exec -it --user librenms `docker container list | grep docker_app | awk {'print $1'}` php adduser.php admin password 10 admin@example.com
DONE
More information about this containersetup here » [https://github.com/librenms/docker]
And at last do not forget your well earned Coffee.