zabbix / zabbix-docker

Official Zabbix Dockerfiles
https://www.zabbix.com
GNU Affero General Public License v3.0
2.39k stars 1.38k forks source link

How to use loadable modules with dependencies? #860

Closed i-ky closed 3 years ago

i-ky commented 3 years ago

Image documentation says:

ZBX_LOADMODULE The variable is list of comma separated loadable Zabbix modules. It works with volume /var/lib/zabbix/modules. The syntax of the variable is dummy1.so,dummy2.so.

This works if dummy1.so and dummy2.so don't have any additional dependencies. That's not always the case. Do you have any suggestions how loadable modules with dependencies should be handled?

One workaround I can imagine is to mount dependencies into container as well, but this can get pretty brittle and ugly if dependency itself has secondary dependencies (e.g. libcurl with different SSL backends).

Another way is to forget about ZBX_LOADMODULE and build an image with a loadable module and all of its dependencies. This is probably too much to ask from end users and such images should be provided by module maintainers. But then we loose "composability", i.e. dummy1.so and dummy2.so are provided in different images and it is impossible to use them together, with a single Zabbix agent.

Would be nice to know what is your vision of this problem. If there are tips for loadable module maintainers and users, then please add them to the documentation.

dotneft commented 3 years ago

If you need something custom - yes, it is better to make your own images based on official one. Or you can build static module with everything included.

i-ky commented 3 years ago

If you need something custom - yes, it is better to make your own images based on official one.

There is no suitable official image for building modules, actually. To build module it is required to pull Zabbix source code of a matching version and, as of today, even configure it. For compatibility it is also desirable to compile module with the same compiler and flags as Zabbix itself.

So I think it would be very nice if Zabbix could provide official images for building loadable modules with Zabbix build dependencies preinstalled, Zabbix sources checked out and configured, compiler flags set as environment variable, etc. Module maintainers would take such image as base for build stage, install module build dependencies and build module. Then as a final stage maintainer would take "runtime" image, install module runtime dependencies and copy module from build stage.

dotneft commented 3 years ago

We do not hide our Dockerfiles, so all flags and compilation method is available. Final image, as you suggested, could be old because of new dev-packages as well, which you probably need to compile your module.

i-ky commented 3 years ago

We do not hide our Dockerfiles, so all flags and compilation method is available.

That's great, but you can change them at any moment, can't you? I would not want to watch your Dockerfiles to keep mine in sync.

Similarly, Linux distributions don't hide sources for their libcurl packages, but still curl-config is a useful tool.

Final image, as you suggested, could be old because of new dev-packages as well, which you probably need to compile your module.

Sorry, I did not get it. Could you please elaborate?

shraik commented 3 years ago

We do not hide our Dockerfiles, so all flags and compilation method is available. Final image, as you suggested, could be old because of new dev-packages as well, which you probably need to compile your module.

hello, can you help me with link to the Dockerfile where to see the assembly of zabbix agent 2 for windows ?

dotneft commented 3 years ago

Please check it https://github.com/zabbix/zabbix-docker/blob/trunk/agent2/windows/Dockerfile. Currently we are checking licensing issues, and if everything is ok, will publish images :-)

dotneft commented 3 years ago

fixed!

shraik commented 3 years ago

I'am cannot build images

~/zabb/zabbix-docker/Dockerfiles/agent2/windows$ sudo docker build . Sending build context to Docker daemon 14.34kB Step 1/24 : ARG MAJOR_VERSION=5.0 Step 2/24 : ARG ZBX_VERSION=${MAJOR_VERSION}.16 Step 3/24 : ARG BUILD_BASE_IMAGE=zabbix-build-agent:ltsc2022-agent2-${ZBX_VERSION} Step 4/24 : ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git Step 5/24 : ARG BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022 Step 6/24 : FROM ${BUILD_BASE_IMAGE} as builder pull access denied for zabbix-build-agent, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

dotneft commented 3 years ago

Please specify correct BUILD_BASE_IMAGE build argument. For example: BUILD_BASE_IMAGE=zabbix/zabbix-build-mysql:agent2-5.0-ltsc2019-latest. You can check list in https://hub.docker.com/r/zabbix/zabbix-build-mysql/tags?page=1&name=ltsc

shraik commented 3 years ago
PS C:\zabbix> ls
    Каталог: C:\zabbix
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        15.10.2021     22:09           9621 docker-entrypoint.ps1
-a----        15.10.2021     22:11           2789 Dockerfile

PS C:\zabbix> docker.exe build .
[+] Building 5.5s (14/16)
[good step]
 => => sha256:a22994ae6a0397ceec7b41ab2a3dd509bb5ba6899f6c3260b9d8b8baa7e09a1d 10.71kB / 10.71kB                   0.0s
 => => sha256:90ac3ced7b4ff95f4cc52c313b141949e4c550c282b69d3532c7a16ce0f5c4b8 37.19kB / 37.19kB                   0.0s
 => CACHED [stage-1 2/6] WORKDIR C:\zabbix\                                                                        0.0s
 => CACHED [stage-1 3/6] COPY --from=builder [C:\\zabbix2, C:\\zabbix]                                             0.0s
 => ERROR [stage-1 4/6] COPY [.\\docker-entrypoint.ps1, C:\\zabbix]                                                0.0s
------
 > [stage-1 4/6] COPY [.\\docker-entrypoint.ps1, C:\\zabbix]:
------
failed to compute cache key: "/.\\docker-entrypoint.ps1" not found: not found
dotneft commented 3 years ago

what OS do you use?

shraik commented 3 years ago

windows 11

shraik commented 3 years ago

image

dotneft commented 3 years ago

try to specify:

COPY [docker-entrypoint.ps1, C:\\zabbix]