You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe that in docker-compose_v3_alpine_pgsql_latest.yaml (possibly in all other Compose files) this repo somewhat recently introduced a regression. When I use HashiCorp Vault as indicated by setting environment variables VAULT_TOKEN, ZBX_VAULT, ZBX_VAULTDBPATH and ZBX_VAULTURL as of roughly the 7.2.x tags docker-entrypoint.sh lines 397 and 398 will indiscriminately Bash export variables ZBX_DB_USER and ZBX_DB_PASSWORD.
The Docker Compose zabbix-server service container will pick this up in its /etc/zabbix/zabbix_server.conf which does an Include=/etc/zabbix/zabbix_server_db.conf which in turn renders both DBUser=${ZBX_DB_USER} and DBPassword=${ZBX_DB_PASSWORD}.
If either DBUser or DBPassword is set Zabbix --entrypoint "/usr/bin/docker-entrypoint.sh" with params "/usr/sbin/zabbix_server", "--foreground", "-c", "/etc/zabbix/zabbix_server.conf" will politely exit.
There seems to be no obvious way to use HashiCorp Vault now which used to work fine with repo version 7.0 and up.
# docker version
Client:
Version: 27.5.1
API version: 1.47
Go version: go1.23.5
Git commit: 9f9e405801
Built: Tue Jan 28 21:43:20 2025
OS/Arch: linux/amd64
Context: default
Server:
Engine:
Version: 27.3.1
API version: 1.47 (minimum version 1.24)
Go version: go1.23.1
Git commit: 41ca978a0a
Built: Wed Sep 25 14:43:43 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v2.0.2
GitCommit: c507a0257ea6462fbd6f5ba4f5c74facb04021f4.m
runc:
Version: 1.2.5
GitCommit:
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Docker Compose version:
# docker compose version
Docker Compose version 2.33.1
Image tags and manifest hashes:
# docker image ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
postgres 16-alpine 1e8624fe3776 9 days ago 275MB
zabbix/zabbix-web-nginx-pgsql alpine-7.2-latest 4df5985dd0e6 9 days ago 228MB
zabbix/zabbix-server-pgsql alpine-7.2-latest 236a5d6fd394 9 days ago 68.9MB
busybox latest 31311c5853a2 4 months ago 4.27MB
Until recently I was running with repo commit hash 77d0151 (tag 7.0.9) which worked fine. What I believe is happening is that back then docker-entrypoint.sh from commit hash 77d0151 used to run an update_zbx_config() Bash function where it would conditionally set DBUser and DBPassword to empty strings when Vault parameters had non-null values:
if [ -n "${ZBX_VAULTDBPATH}" ]; then
update_config_var $ZBX_CONFIG "DBUser"
update_config_var $ZBX_CONFIG "DBPassword"
else
...
fi
This allowed Zabbix to start just fine.
Somewhere around the 7.2.x tags - I believe specifically as of commit hash 688ed8b - this no longer works. Now both DBUser=${ZBX_DB_USER} and DBPassword=${ZBX_DB_PASSWORD} persist with non-null values and Zabbix exits on container start when it also has Vault params. Commit hash 688ed8b is contained in both the 7.2.2 and the 7.2.3 tags.
STEPS TO REPRODUCE
First without HashiCorp Vault params to confirm we're not forgetting anything.
Clone repo https://github.com/zabbix/zabbix-docker, for example into /opt/git/github.com/zabbix/zabbix-docker/branches/latest:
cd into repo so Docker Compose can render a suitable --project-name from your current working directory:
cd "${UPSTREAM_REPO_DIR}"
export UPSTREAM_COMPOSE_FILE="${UPSTREAM_REPO_DIR%/}"'/docker-compose_v3_alpine_pgsql_latest.yaml'
(Optional) Get your bearing, Docker Compose will render this setup like this pastebin snippet at http://0x0.st/8T9S.txt. Snippet will auto-delete a month from now on Tuesday, March 25, 2025, 08:34:51 UTC:
At this time this will pull the following image tags and manifest hashes:
# docker image ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
postgres 16-alpine 869ba6a9adbd 2 days ago 275MB
zabbix/zabbix-web-nginx-pgsql alpine-7.2-latest 4df5985dd0e6 9 days ago 228MB
zabbix/zabbix-server-pgsql alpine-7.2-latest 236a5d6fd394 9 days ago 68.9MB
busybox latest 31311c5853a2 4 months ago 4.27MB
docker compose --file "${UPSTREAM_COMPOSE_FILE}" up --detach
Visit your new empty Zabbix instance at whatever your fully.qualified.domain.name is:
Stop your instance, redo with HashiCorp Vault params.
To both env_vars/.env_web and env_vars/.env_srv add the same four Vault parameters that work fine with commit hash 77d0151 (tag 7.0.9). You've confirmed they are able to retrieve the zabbix secret with both its username and password key and both keys have their value set to zabbix as per env_vars/.POSTGRES_PASSWORD and env_vars/.POSTGRES_USER:
(Optional) Render the updated Docker Compose config to confirm that your added parameters are picked up correctly as in this pastebin snippet at http://0x0.st/8T9I.txt. Snippet will auto-delete a month from now on Tuesday, March 25, 2025, 09:22:26 UTC.
This will create a diff to your first version like so where both the zabbix-server Docker Compose service and the zabbix-web-nginx-pgsql service now contain additional env vars:
When I next render the resulting config (with --file compose.override.yaml) I confirm that a new bind mount overwrites the container's docker-entrypoint.sh file:
SUMMARY
Hi!
I believe that in docker-compose_v3_alpine_pgsql_latest.yaml (possibly in all other Compose files) this repo somewhat recently introduced a regression. When I use HashiCorp Vault as indicated by setting environment variables
VAULT_TOKEN
,ZBX_VAULT
,ZBX_VAULTDBPATH
andZBX_VAULTURL
as of roughly the 7.2.x tags docker-entrypoint.sh lines 397 and 398 will indiscriminately Bashexport
variablesZBX_DB_USER
andZBX_DB_PASSWORD
.The Docker Compose
zabbix-server
service container will pick this up in its/etc/zabbix/zabbix_server.conf
which does anInclude=/etc/zabbix/zabbix_server_db.conf
which in turn renders bothDBUser=${ZBX_DB_USER}
andDBPassword=${ZBX_DB_PASSWORD}
.If either
DBUser
orDBPassword
is set Zabbix--entrypoint "/usr/bin/docker-entrypoint.sh"
with params"/usr/sbin/zabbix_server"
,"--foreground"
,"-c"
,"/etc/zabbix/zabbix_server.conf"
will politely exit.There seems to be no obvious way to use HashiCorp Vault now which used to work fine with repo version 7.0 and up.
OS / ENVIRONMENT / Used docker-compose files
This is running docker-compose_v3_alpine_pgsql_latest.yaml on an Arch Linux rolling release machine.
Docker version:
Docker Compose version:
Image tags and manifest hashes:
CONFIGURATION
In both env_vars/.env_web and env_vars/.env_srv I set:
Until recently I was running with repo commit hash 77d0151 (tag 7.0.9) which worked fine. What I believe is happening is that back then docker-entrypoint.sh from commit hash 77d0151 used to run an
update_zbx_config()
Bash function where it would conditionally setDBUser
andDBPassword
to empty strings when Vault parameters had non-null values:This allowed Zabbix to start just fine.
Somewhere around the 7.2.x tags - I believe specifically as of commit hash 688ed8b - this no longer works. Now both
DBUser=${ZBX_DB_USER}
andDBPassword=${ZBX_DB_PASSWORD}
persist with non-null values and Zabbix exits on container start when it also has Vault params. Commit hash 688ed8b is contained in both the 7.2.2 and the 7.2.3 tags.STEPS TO REPRODUCE
First without HashiCorp Vault params to confirm we're not forgetting anything.
https://github.com/zabbix/zabbix-docker
, for example into/opt/git/github.com/zabbix/zabbix-docker/branches/latest
:cd
into repo so Docker Compose can render a suitable--project-name
from your current working directory:dhparam
file or generate one yourself. The lazy way uses for example Mozilla's file:"${UPSTREAM_REPO_DIR}"'/env_vars'
*CERT_FILE
and*KEY_FILE
over to"${UPSTREAM_REPO_DIR}"'/zbx_env/etc/ssl/nginx'
asssl.crt
andssl.key
:fully.qualified.domain.name
is:Stop your instance, redo with HashiCorp Vault params.
zabbix
secret with both itsusername
andpassword
key and both keys have their value set tozabbix
as perenv_vars/.POSTGRES_PASSWORD
andenv_vars/.POSTGRES_USER
:zabbix-server
Docker Compose service and thezabbix-web-nginx-pgsql
service now contain additional env vars:zabbix-server-1
container exits:Notice that the
zabbix-web-nginx-pgsql
Compose service doesn't have the same issue as it uses a different mechanism to unset database credentials.EXPECTED RESULTS
Zabbix server container does either one of the two:
DBUser
andDBPassword
for me when Vault params are presentPOSTGRES_PASSWORD
andPOSTGRES_USER
(or their_FILE
counterparts)ACTUAL RESULTS
Zabbix server container politely points out that
DBUser
andDBPassword
must be unset or null when Vault params are present.My quick and dirty workaround is to use docker-entrypoint.sh and to comment out lines 397 and 398 like so:
I then place a
compose.override.yaml
file in the Git repo's root dir like so:When I next render the resulting config (with
--file compose.override.yaml
) I confirm that a new bind mount overwrites the container'sdocker-entrypoint.sh
file:This picks up my own docker-entrypoint.sh as a bind mount into the container:
Is there a cleaner/better way to use HashiCorp Vault params with repo tags 7.2 and up?
Thanks!
The text was updated successfully, but these errors were encountered: