jjethwa / icinga2

GNU General Public License v3.0
222 stars 189 forks source link

Please add an editor to the image #217

Open DvagNic opened 4 years ago

DvagNic commented 4 years ago

Since config files have to be edited inside the container, it would be nice if the image would include vim or another editor. I know that if one uses volumes, one can edit the files on the host, but for Docker on the Mac the volumes are located inside a "hidden" VM and it is not that easy to reach that VM. Editing from within the container makes life easier :)

jjethwa commented 4 years ago

Hi @DvagNic

I think there was a security recommendation not to include editors in production ready images. Is there any way to get easy access to those volumes? Sorry, I've never used Docker for Mac, so I don't know offhand 😄

xurizaemon commented 3 years ago

@DvagNic a few options to consider. Caveat that I'm not on Mac, so the first two of these I'm less sure of given your initial report.

Edit the files directly

You can directly edit the relevant configuration files from outside the running Docker images. For example, to modify /etc/icinga2/conf.d/users.conf inside the container, you can edit data/icinga2/etc/icinga2/conf.d/users.conf in your local project. This may require fiddling with permissions in the host OS, or using sudo to bypass permissions (then perhaps fiddling with them later).

Use another docker image to obtain vim

If it's significant to you that the files be edited from within a running Docker image, you can do that too, and without needing to modify the base images. Use docker run with another base image (eg dilshad/alpinevim is a Docker image with just vim available), and specify the relevant volumes. This gives you the existing, no-vim base images from this project, and a ready way to execute vim alongside those running images as required.

docker run -ti -v /home/dvagnic/docker-icinga2/data/icinga/etc/icinga2:/etc/icinga2 dilshad/alpinevim vim /etc/icinga2

You could add such a configuration to the images in this project's docker-compose.yml for your own use.

Fork and modify jordan/icinga2 base image

If you needed to be able to deploy a version of this with vim pre-installed, that's possible from a Docker image which extends jordan2/icinga2 Docker image. Something like,

FROM jordan/icinga2

apt-get install vim

Publish that image somewhere (eg DockerHub), then consume it from a modified docker-compose.yml and you're in business.

Hope that helps!