Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am unable to map out all of /opt/ with -v command. #125

Closed
jaxjexjox opened this issue Dec 6, 2020 · 5 comments
Closed

I am unable to map out all of /opt/ with -v command. #125

jaxjexjox opened this issue Dec 6, 2020 · 5 comments

Comments

@jaxjexjox
Copy link

As soon as I map out ALL of /opt/ it breaks the container ability to run.

$sudo docker exec librenms setup_database
Error response from daemon: Container 1c04ac3fe0a0413c3549a643017ff65fbec9a2d5eafd6ddb803e1768817a53a2 is restarting, wait until the container is running

There is probably a totally good reason for this, I'm sure!
I'm a newbie with LibreNMS but I've found multiple references online which help me with it, by editing content inside /opt or even adding files (plugins)

I would like to be able to destroy and recreate with new versions, I'm unable to do this, if I have content, inside the container itself (at least I finally know how to work, inside the container)

I also tried digging deeper, this doesn't work either:
-v /dockerconfigs/librenms/opt/helpers:/opt/helpers
-v /dockerconfigs/librenms/opt/librenms:/opt/librenms \

So, surely I'm not the only one who wants this? There's many a forum post about downloading extra files allowing for inspecting more services or editing files which allow you to define, for example the IP range you wish to scan (or if you want to scan at all)

Etc.

What am I doing wrong here?
(Thank you!)

@jaxjexjox
Copy link
Author

jaxjexjox commented Dec 6, 2020

While I'm at it, I just checked my existing, working build.

/usr/lib/nagios/plugins - I had to add a file called "check_224" if I recall. It added functionality I wanted.

Here's the line I just tried, so my new 'better' build has files mapped out and writable.
-v /dockerconfigs/librenms/usr/lib/nagios/plugins:/usr/lib/nagios/plugins \

Unfortunately, this line results in a container, with an empty plugins folder... How can I make the plugins folder read / write AND contain the contents of the latest pulled image? (I assumed this was the point of -v)

Thank you!

@jarischaefer
Copy link
Owner

The problem with overwriting directories or files inside the container is that you are actually replacing/hiding the original directories/files by using -v. This means that the original content is lost. If you mount an empty directory from the host to /opt/librenms then the entire LibreNMS installation inside the image is replaced by an empty directory on the host.

There are multiple ways to work around this:

  1. Only mount new directories as children of existing ones. If you want a subdirectory bar inside foo (/foo/bar), but /foo already exists in the container, you could define the mount as follows: -v /directory_on_the_host:/foo/bar
  2. Adding files works the same way, except that files must already exist on the host before starting the container. Otherwise, Docker will assume that the left part (source) of -v is supposed to be a directory and create it if it does not exist. Therefore, you would have to use touch /foo.txt to create the file on the host and after that you may start the container with -v /foo.txt:/opt/librenms/foo.txt.
  3. A container may also offer special locations (see docs about custom config) where you could overwrite the entire directory. But this requires logic inside the container (see https://github.com/jarischaefer/docker-librenms/blob/master/files/opt/librenms/config.php#L45).

When you are dealing with a lot of files, using options 1 and 2 may be undesirable due to the need for one -v entry per file and also the need to restart the container after every change. If your use case is to complement the existing plugins in /usr/lib/nagios with your own plugins, then I could add a new feature that would introduce a separate directory for that. This would allow you to mount an entire directory (e.g. /mount/nagios_plugins) instead of individual files and have some logic inside the container wire everything together.

Let me know if you require the feature resembling option 3 for nagios plugins and whether this explanation clears things up.

@jaxjexjox
Copy link
Author

Hi Jaris,

Thanks for the reply, sorry I've been busy.
This is my fault due to knowledge, not really fault of the docker image.

You're absoloutely right - dealing with lots of files makes option 1 and 2 not ideal unfortunately. Especially as I may want to add plugins ad_hoc later on "oh this might be nice, let me grab this nagios plugin".

"then I could add a new feature that would introduce a separate directory for that. This would allow you to mount an entire directory (e.g. /mount/nagios_plugins)"

I think this would be ideal to be honest, very kind of you to offer, although I'm curious how others, much smarter than I are already dealing with this? Surely there's a solution now?

@jaxjexjox
Copy link
Author

and look one thing, while I'm at is, the whole reason I want to map things out is the normal applications I use via docker, I have all the data writing out to /NAS/Filesystem/ and ALL the config writing out to /VirtualMachine/Docker/
All my containers are entirely disposable. I can stop, remove, destroy, recreate them and they seem to import all my settings and just work.

With LibreNMS I'm wanting to achieve the ability to safely update the software. Hence 'mapping out' everything I can, safely.
I believe with a custom.config.php mapped out, my logs, RRD and nagios plugins, I should be able to destroy and recreate safely. I hope.

@jarischaefer
Copy link
Owner

The latest build contains a new feature which is described here. Please let me know whether this solves the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants