Table of Contents
Zabbix - Template - Docker
Configure
Download and import the official Docker Template.
Make sure, zabbix_agent2 is installed on the server. Add the zabbix user to the docker group and restart the service.
usermod -aG docker zabbix systemctl restart zabbix-agent2.service
Problems
Cannot fetch data
root@dockerhost:~# sudo -u zabbix zabbix_agent2 -t docker.info docker.info [m|ZBX_NOTSUPPORTED] [Cannot fetch data: Get "http://1.28/info": dial unix /run/containerd/containerd.sock: connect: permission denied.]
The zabbix user isn't allowed to access /run/containerd/containerd.sock. This can happen, if the user zabbix is not part of the group docker. To fix it:
usermod -aG docker zabbix
Failed writing received data to disk/application.
Suddenly, I got all problem notification from my Pushover action three times, which is the maximal retry count for failed actions. In the problem overview, the notification arrow was red and showed me the error: “Pushover notification failed: Error: cannot get URL: Failed writing received data to disk/application.”. I did some research and found an issue on GitHub with the same problem on Debian. Version 8.7.1 is affected but on Debian it is fixed in 8.7.1-5. My Zabbix containers use the latest Alpine Linux v3.20 with libcurl-8.7.1-r1. Finally I also found the Zabbix support ticket ZBX-23702.
Thank you Dmitry Verkhoturov for the hint to use “$(apk –print-arch)” to determine the used architecture instead of the hardcoded “x86_64” and the line to add to a Dockerfile. Updated: 2024-07-11
Docker
I did a temporary solution to the problem until a new revision or version of libcurl lands in the Alpine Linux repositories. It needs to be re-applied on every container creation again.
In my case, the Zabbix server container is named root-zabbix-server-1. Check the name on your system with “docker ps”.
Start a bash process in the Zabbix server container as user root (default is user zabbix).
docker exec -it -u root root-zabbix-server-1 bash
Check the currently installed libcurl version.
apk list libcurl
If you see libcurl-8.7.1-r0, you can proceed to apply the fix.
- Example
6cdf75e0dde7:/var/lib/zabbix# apk list --installed libcurl libcurl-8.7.1-r0 x86_64 {curl} (curl) [installed]
Download libcurl-8.8.0-r1 (link for x86_64 repository) from the edge repository.
wget https://dl-cdn.alpinelinux.org/alpine/edge/main/$(apk --print-arch)/libcurl-8.8.0-r1.apk
Install the package.
apk add libcurl-8.8.0-r1.apk
Check if the new version is installed. If you see libcurl-8.8.0-r1, the installation was successful.
apk list --installed libcurl
- Example
6cdf75e0dde7:/var/lib/zabbix# apk list --installed libcurl libcurl-8.8.0-r1 x86_64 {curl} (curl) [installed]
Remove the apk file.
rm libcurl-8.8.0-r1.apk
Exit the bash process of the container.
exit
Restart the Zabbix server container.
docker restart root-zabbix-server-1
Dockerfile
In case you maintain your own Dockerfile, the following line can fix the problem.
RUN wget "https://dl-cdn.alpinelinux.org/alpine/edge/main/$(apk --print-arch)/libcurl-8.8.0-r1.apk" && apk add libcurl-8.8.0-r1.apk && rm libcurl-8.8.0-r1.apk