Cannot add hosts to hosts.conf on a Docker container witch Icinga


I’m trying to add fron the CLI some hosts editing the hosts.conf file (inside it there are some hosts that someone added in the past) but I’m encountering an issue!

Icinga is in a Docker container, so I do this:

  • Use the docker cp command for copy the file from the container to my directory;
  • Edit the hosts.conf file that I have copied looking how are inserted the other hosts;
  • Rename the original file in the docker container from hosts.conf to hosts.conf.orig;
  • Use the docker cp command for copy my edited hosts.conf file in the container (in the correct path).

Than, for some reason the container exites with code 0 after 20 seconds (more or less) and if I try to turn it up, it goes up but exites in few seconds…

I re-established the original situation (luckily :four_leaf_clover:) by copying and pasting commands within 20 seconds the container is on, but I don’t explain why this is happening.

How do I add hosts from CLI in this case?

Thank you



what about using the REST-API? You could do this form the CLI using curl for example. Hosts and objects as such can be created via PUT calls.

The documentation has a few examples:

1 Like