Hey all,
Has anyone installed LibreNMS in a Docker Container? I’d like to do that. I have found the recommended YAML compose file, but as I’m not a YAML expert, I’m not sure what needs to be changed for the QNAP, etc.
Thanks!
Hey all,
Has anyone installed LibreNMS in a Docker Container? I’d like to do that. I have found the recommended YAML compose file, but as I’m not a YAML expert, I’m not sure what needs to be changed for the QNAP, etc.
Thanks!
Can you post the yaml?
mostly networking and shared folders would need adapting for WNAP
name: librenms
services:
db:
image: mariadb:10
container_name: librenms_db
command:
- "mysqld"
- "--innodb-file-per-table=1"
- "--lower-case-table-names=0"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
volumes:
- "./db:/var/lib/mysql"
environment:
- "TZ=${TZ}"
- "MARIADB_RANDOM_ROOT_PASSWORD=yes"
- "MYSQL_DATABASE=${MYSQL_DATABASE}"
- "MYSQL_USER=${MYSQL_USER}"
- "MYSQL_PASSWORD=${MYSQL_PASSWORD}"
restart: always
redis:
image: redis:7.2-alpine
container_name: librenms_redis
environment:
- "TZ=${TZ}"
restart: always
msmtpd:
image: crazymax/msmtpd:latest
container_name: librenms_msmtpd
env_file:
- "./msmtpd.env"
restart: always
librenms:
image: librenms/librenms:latest
container_name: librenms
hostname: librenms
cap_add:
- NET_ADMIN
- NET_RAW
ports:
- target: 8000
published: 8000
protocol: tcp
depends_on:
- db
- redis
- msmtpd
volumes:
- "./librenms:/data"
env_file:
- "./librenms.env"
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"
restart: always
dispatcher:
image: librenms/librenms:latest
container_name: librenms_dispatcher
hostname: librenms-dispatcher
cap_add:
- NET_ADMIN
- NET_RAW
depends_on:
- librenms
- redis
volumes:
- "./librenms:/data"
env_file:
- "./librenms.env"
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"
- "DISPATCHER_NODE_ID=dispatcher1"
- "SIDECAR_DISPATCHER=1"
restart: always
syslogng:
image: librenms/librenms:latest
container_name: librenms_syslogng
hostname: librenms-syslogng
cap_add:
- NET_ADMIN
- NET_RAW
depends_on:
- librenms
- redis
ports:
- target: 514
published: 514
protocol: tcp
- target: 514
published: 514
protocol: udp
volumes:
- "./librenms:/data"
env_file:
- "./librenms.env"
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"
restart: always
snmptrapd:
image: librenms/librenms:latest
container_name: librenms_snmptrapd
hostname: librenms-snmptrapd
cap_add:
- NET_ADMIN
- NET_RAW
depends_on:
- librenms
- redis
ports:
- target: 162
published: 162
protocol: tcp
- target: 162
published: 162
protocol: udp
volumes:
- "./librenms:/data"
env_file:
- "./librenms.env"
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_SNMPTRAPD=1"
restart: always
On QTS you would do your share declarations with /share/sharename/subfolder
So I do mine like this (httpd container as an example)
volumes:
- '/share/Web/webstage1:/usr/local/apache2/htdocs'
So in this case I have a folder in my Share ‘Web’ named ‘webstage1’
This will be mounted within the container as /usr/local/apache2/htdocs
If you want to make this read only (e.g. files you do NOT want the container to edit, you declare this :ro at the end
volumes:
- '/share/Web/webstage1:/usr/local/apache2/htdocs:ro'
So that’s the folder that is “outside” of the QNAP docker filesystem. So I would have mine in /share/Container/LibreNMS in this case. Correct?
Now, do I need to install MariaDB and do I need to setup all the password and database, etc?
???
You would do that for all volumes
The database should be part of the compose package, only thing you need to adjust, is volumes and networking (if you don’t want NAT, but bridging for instance) and whatever changes to usernames and passwords you want.
OK. So I ended up with this as my compose file:
name: librenms
services:
db:
image: mariadb:10
container_name: librenms_db
command:
- "mysqld"
- "--innodb-file-per-table=1"
- "--lower-case-table-names=0"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
volumes:
- "/share/Container/LibreNMS/db:/var/lib/mysql"
environment:
- "TZ=${TZ}"
- "MARIADB_RANDOM_ROOT_PASSWORD=yes"
- "MYSQL_DATABASE=${MYSQL_DATABASE}"
- "MYSQL_USER=${MYSQL_USER}"
- "MYSQL_PASSWORD=${MYSQL_PASSWORD}"
restart: always
redis:
image: redis:7.2-alpine
container_name: librenms_redis
environment:
- "TZ=${TZ}"
restart: always
msmtpd:
image: crazymax/msmtpd:latest
container_name: librenms_msmtpd
env_file:
- "/share/Container/LibreNMS/msmtpd.env"
restart: always
librenms:
image: librenms/librenms:latest
container_name: librenms
hostname: librenms
cap_add:
- NET_ADMIN
- NET_RAW
ports:
- target: 8000
published: 8000
protocol: tcp
depends_on:
- db
- redis
- msmtpd
volumes:
- "/share/Container/LibreNMS:/data"
env_file:
- "/share/Container/LibreNMS/librenms.env"
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"
restart: always
dispatcher:
image: librenms/librenms:latest
container_name: librenms_dispatcher
hostname: librenms-dispatcher
cap_add:
- NET_ADMIN
- NET_RAW
depends_on:
- librenms
- redis
volumes:
- "/share/Container/LibreNMS:/data"
env_file:
- "/share/Container/LibreNMS/librenms.env"
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"
- "DISPATCHER_NODE_ID=dispatcher1"
- "SIDECAR_DISPATCHER=1"
restart: always
syslogng:
image: librenms/librenms:latest
container_name: librenms_syslogng
hostname: librenms-syslogng
cap_add:
- NET_ADMIN
- NET_RAW
depends_on:
- librenms
- redis
ports:
- target: 514
published: 514
protocol: tcp
- target: 514
published: 514
protocol: udp
volumes:
- "/share/Container/LibreNMS:/data"
env_file:
- "/share/Container/LibreNMS/librenms.env"
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"
restart: always
snmptrapd:
image: librenms/librenms:latest
container_name: librenms_snmptrapd
hostname: librenms-snmptrapd
cap_add:
- NET_ADMIN
- NET_RAW
depends_on:
- librenms
- redis
ports:
- target: 162
published: 162
protocol: tcp
- target: 162
published: 162
protocol: udp
volumes:
- "/share/Container/LibreNMS:/data"
env_file:
- "/share/Container/LibreNMS/librenms.env"
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_SNMPTRAPD=1"
restart: always
cap_add:
- NET_ADMIN
- NET_RAW
ports:
- target: 8000
published: 8000
protocol: tcp
depends_on:
- db
- redis
- msmtpd
volumes:
- "/share/Container/LibreNMS:/data"
env_file:
- "/share/Container/LibreNMS/librenms.env"
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"
restart: always
dispatcher:
image: librenms/librenms:latest
container_name: librenms_dispatcher
hostname: librenms-dispatcher
cap_add:
- NET_ADMIN
- NET_RAW
depends_on:
- librenms
- redis
volumes:
- "/share/Container/LibreNMS:/data"
env_file:
- "/share/Container/LibreNMS/librenms.env"
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"
- "DISPATCHER_NODE_ID=dispatcher1"
- "SIDECAR_DISPATCHER=1"
restart: always
syslogng:
image: librenms/librenms:latest
container_name: librenms_syslogng
hostname: librenms-syslogng
cap_add:
- NET_ADMIN
- NET_RAW
depends_on:
- librenms
- redis
ports:
- target: 514
published: 514
protocol: tcp
- target: 514
published: 514
protocol: udp
volumes:
- "./librenms:/data"
env_file:
- "./librenms.env"
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"
restart: always
snmptrapd:
image: librenms/librenms:latest
container_name: librenms_snmptrapd
hostname: librenms-snmptrapd
cap_add:
- NET_ADMIN
- NET_RAW
depends_on:
- librenms
- redis
ports:
- target: 162
published: 162
protocol: tcp
- target: 162
published: 162
protocol: udp
volumes:
- "/share/Container/LibreNMS:/data"
env_file:
- "/share/Container/LibreNMS/librenms.env"
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_SNMPTRAPD=1"
restart: always
But it’s generating errors. On the GitHub repository, this a .env file which contains this:
TZ=Europe/Paris
PUID=1000
PGID=1000
MYSQL_DATABASE=librenms
MYSQL_USER=librenms
MYSQL_PASSWORD=asupersecretpassword
I am getting errors on these variables. I assume instead that I should just enter those values into the Compose file?
Additionally, they have two other files:
librenms.env
MEMORY_LIMIT=256M
MAX_INPUT_VARS=1000
UPLOAD_MAX_SIZE=16M
OPCACHE_MEM_SIZE=128
REAL_IP_FROM=0.0.0.0/32
REAL_IP_HEADER=X-Forwarded-For
LOG_IP_VAR=remote_addr
CACHE_DRIVER=redis
SESSION_DRIVER=redis
REDIS_HOST=redis
LIBRENMS_SNMP_COMMUNITY=librenmsdocker
LIBRENMS_WEATHERMAP=false
LIBRENMS_WEATHERMAP_SCHEDULE=*/5 * * * *
and msmtpd.env
# https://github.com/crazy-max/docker-msmtpd
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_TLS=on
SMTP_STARTTLS=on
SMTP_TLS_CHECKCERT=on
SMTP_AUTH=on
SMTP_USER=foo
SMTP_PASSWORD=bar
SMTP_FROM=foo@gmail.com
Do I put these files in the /share/Container/LibreNMS folder before I build the app? Yes, I know I need to change the values.
I have never used them I think
But I think you can bind them to a user/group of the NAS
id admin (would be the default anyways), if you want to
Would spit out PUID and GUID of admin, if you want to run the container with other permissions, check the values for whatever user you want to run this as
See also
I think maybe you misunderstood my question..
I should be able to create whatever username/password I want. As far as the container knows, it’s got nothing to do with the NAS. So for the .env file, I can enter those into the compose script.
It’s what to do with the librenms.env and msmtpd.env files.
No idea, I never created a container with env variables
The containers I have used all fit in the compose window and had config files in the shares.
Sorry
OK. Well, let me see what I can do! ![]()
OK, so ContainerStation is throwing an error here in the Compose file at the “cap_add:” line. Any idea what that is for?
- "DB_PASSWORD=xxxxx"
- "DB_TIMEOUT=60"
- "SIDECAR_SNMPTRAPD=1"
restart: always
cap_add:
- NET_ADMIN
- NET_RAW
ports:
- target: 8000
published: 8000
protocol: tcp
Here is a quick google find
If this throws an error, maybe it’s not implemented in QNAPs docker version?
Yeah, maybe it’s not implemented? That is strange.
I was thinking of trying:
CAP_NET_ADMIN
CAP_NET_RAW
right in the Compose file. Or would that definitely not work?
What happens when you leave it out?
Otherwise you can check the compose handbook
So there was a major flaw in my compose file. I had accidentally duplicated a bunch of stuff at the end. Those cap_add: commands were fine. They were accepted in other locations of the file without issue. Somehow I copied and pasted stuff in more than once.
Now you do have to have those .env files in place in the directory you specify BEFORE you attempt to validate your YAML code. If you don’t, you will get an error.
With everything in place and built correctly, I now have successfully created the application but it created 7 containers all with their own IP addresses. Everything is using the IP range that QNAP provides in Network and Virtual Switch. I now need to figure out what to do with these. Do I put them on my main network or do I leave them be? So far, I’ve not been able to access any webpages for LibreNMS or anything. So more investigative work to do. But the good news is that I have it running…
Grrr. This thing seems to be quite complex…
The app is continually crashing and restarting. Getting an error here…
Creating LibreNMS daily.sh cron task with the following period fields: 15 0 * * *
Creating LibreNMS cron artisan schedule:run
Fixing crontabs permissions…
chmod: changing permissions of ‘/var/spool/cron/crontabs/librenms’: Bad address
I’m guessing QNAP isn’t liking the /var pathname. Maybe I need to map that to an external path? I can’t go into a shell and see if it is accessible as it crashes and restarts too quickly.
Going to try mapping /var externally…