Making changes persist in config.php when using a docker container

Hi – I’m trying to figure out where to place changes I’d like to make that would typically be in a config.php file while using a docker container.

I have Librenms (and associated containers) up and running, I’d just like to modify a few things.

The first two are:

$config[‘force_ip_to_sysname’] = true;
$config[‘force_hostname_to_sysname’] = true;

I read about the yaml files for /config directory for specific aspects (webui, snmp, etc) but can’t seem to find a location for the general settings (like the ones listed above).

Any help would be greatly appreciated.

Thank you!

Can you put them in the environment?

Best solution I found was not to use config.php at all, you can run the command “lnms config:set” on the docker and it writes the config into the database so it remains permanent. It the added benefit of not locking the config in when you use setting in the WEBUI.

So in your case the command would be:

lnms config:set force_ip_to_sysname true
lnms config:set force_hostname_to_sysname true

you should experiment with “lnms --help, lnms config:get, etc…”

Now you can run it as command during docker creation:

services:
  librenms:
    image: librenms/librenms:latest
    container_name: librenms
    hostname: librenms
    command:
    - sh -c "lnms config:set force_ip_to_sysname true"

may need to fix the format a little (I use kubernetties)

Another trick I find very useful is to make an alias on the host for lnms pointing to the librenms container.

alias lnms="docker exec -ti librenms /usr/bin/lnms "

This allows you to use lnms form the host add remove device and other cool stuff.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.