Using volumes to store persistent data - exasol/nagios-monitoring GitHub Wiki
If you want to update your nagios-monitoring container and reuse the configuration and saved states you have to use docker volumes. We need to save the following container directories:
Path | Description |
---|---|
/etc/nagios/conf.d | Nagios configuration |
/var/lib/nagios | stored states and check results |
/var/cache/nagios | current stats and check results |
/var/log/nagios | Nagios log file directory |
/opt/pnp4nagios/var | pnp4nagios RRD storage (performance results) |
The following example shows how these folder can be stored persistently using bind mounts.
nstorage="/var/tmp/nagiosstorage" #define where to store the Nagios data
mkdir -p ${nstorage}/conf ${nstorage}/lib ${nstorage}/cache ${nstorage}/log ${nstorage}/pnp4nagios #create necessary directories
chmod 777 ${nstorage}/conf ${nstorage}/lib ${nstorage}/cache ${nstorage}/log ${nstorage}/pnp4nagios #allow full access for the container
chmod 555 ${nstorage} #but restrict write access on storage root
#now create the Nagios container instance using external volumes
docker create -p1443:443 \
-v ${nstorage}/conf:/etc/nagios/conf.d:rw,z \
-v ${nstorage}/lib:/var/lib/nagios:rw,z \
-v ${nstorage}/cache:/var/cache/nagios:rw,z \
-v ${nstorage}/log:/var/log/nagios:rw,z \
-v ${nstorage}/pnp4nagios:/opt/pnp4nagios/var:rw,z \
--name exasol-nagios \
--hostname exasol-nagios \
exasol/nagios-monitoring:latest
#start up the Nagios container - and enjoy ;)
docker start exasol-nagios
Instead of bind mounts you can also use docker volumes instead (see https://docs.docker.com/storage/volumes/ for more information).
Hint: you can mount the "/var/lib/nagios" directory in other docker containers to get access to the Nagios socket. This allows additional connectors and tools like Thruk or check_mk to use and manage the Nagios check results.