diff --git a/agent/alpine/Dockerfile b/agent/alpine/Dockerfile index 5c6de71f2..45d9ff5d9 100644 --- a/agent/alpine/Dockerfile +++ b/agent/alpine/Dockerfile @@ -10,9 +10,10 @@ LABEL org.opencontainers.image.title="Zabbix agent" \ STOPSIGNAL SIGTERM RUN set -eux && \ - addgroup zabbix && \ + addgroup -S -g 1000 zabbix && \ adduser -S \ -D -G zabbix \ + -u 999 \ -h /var/lib/zabbix/ \ zabbix && \ mkdir -p /etc/zabbix && \ diff --git a/agent/alpine/docker-entrypoint.sh b/agent/alpine/docker-entrypoint.sh index cb96852d9..2f3aafe31 100755 --- a/agent/alpine/docker-entrypoint.sh +++ b/agent/alpine/docker-entrypoint.sh @@ -104,7 +104,6 @@ update_config_multiple_var() { prepare_zbx_agent_config() { echo "** Preparing Zabbix agent configuration file" - ZBX_AGENT_CONFIG=$ZABBIX_ETC_DIR/zabbix_agentd.conf : ${ZBX_PASSIVESERVERS:=""} @@ -172,6 +171,12 @@ prepare_zbx_agent_config() { update_config_var $ZBX_AGENT_CONFIG "TLSKeyFile" "${ZBX_TLSKEYFILE}" update_config_var $ZBX_AGENT_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}" update_config_var $ZBX_AGENT_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}" + + if [ "$(id -u)" != '0' ]; then + update_config_var $ZBX_AGENT_CONFIG "User" "$(whoami)" + else + update_config_var $ZBX_AGENT_CONFIG "AllowRoot" "1" + fi } prepare_agent() { diff --git a/java-gateway/alpine/Dockerfile b/java-gateway/alpine/Dockerfile index 7e7efca86..9e6acd213 100644 --- a/java-gateway/alpine/Dockerfile +++ b/java-gateway/alpine/Dockerfile @@ -10,9 +10,10 @@ LABEL org.opencontainers.image.title="Zabbix Java Gateway" \ STOPSIGNAL SIGTERM RUN set -eux && \ - addgroup zabbix && \ + addgroup -S -g 1000 zabbix && \ adduser -S \ -D -G zabbix \ + -u 999 \ -h /var/lib/zabbix/ \ zabbix && \ mkdir -p /etc/zabbix/ && \ diff --git a/proxy-mysql/alpine/Dockerfile b/proxy-mysql/alpine/Dockerfile index efb775e20..303b61c63 100644 --- a/proxy-mysql/alpine/Dockerfile +++ b/proxy-mysql/alpine/Dockerfile @@ -10,9 +10,10 @@ LABEL org.opencontainers.image.title="Zabbix proxy (MySQL)" \ STOPSIGNAL SIGTERM RUN set -eux && \ - addgroup zabbix && \ + addgroup -S -g 1000 zabbix && \ adduser -S \ -D -G zabbix \ + -u 999 \ -h /var/lib/zabbix/ \ zabbix && \ mkdir -p /etc/zabbix && \ diff --git a/proxy-mysql/alpine/docker-entrypoint.sh b/proxy-mysql/alpine/docker-entrypoint.sh index a529e8172..a666e81ff 100755 --- a/proxy-mysql/alpine/docker-entrypoint.sh +++ b/proxy-mysql/alpine/docker-entrypoint.sh @@ -375,6 +375,12 @@ update_zbx_config() { update_config_var $ZBX_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}" update_config_var $ZBX_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}" + + if [ "$(id -u)" != '0' ]; then + update_config_var $ZBX_CONFIG "User" "$(whoami)" + else + update_config_var $ZBX_CONFIG "AllowRoot" "1" + fi } prepare_proxy() { diff --git a/proxy-sqlite3/alpine/Dockerfile b/proxy-sqlite3/alpine/Dockerfile index 3a261a661..6d715414b 100644 --- a/proxy-sqlite3/alpine/Dockerfile +++ b/proxy-sqlite3/alpine/Dockerfile @@ -10,9 +10,10 @@ LABEL org.opencontainers.image.title="Zabbix proxy (SQLite3)" \ STOPSIGNAL SIGTERM RUN set -eux && \ - addgroup zabbix && \ + addgroup -S -g 1000 zabbix && \ adduser -S \ -D -G zabbix \ + -u 999 \ -h /var/lib/zabbix/ \ zabbix && \ mkdir -p /etc/zabbix && \ diff --git a/proxy-sqlite3/alpine/docker-entrypoint.sh b/proxy-sqlite3/alpine/docker-entrypoint.sh index adec5d7a6..0b44ead4b 100755 --- a/proxy-sqlite3/alpine/docker-entrypoint.sh +++ b/proxy-sqlite3/alpine/docker-entrypoint.sh @@ -225,6 +225,12 @@ update_zbx_config() { update_config_var $ZBX_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}" update_config_var $ZBX_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}" + + if [ "$(id -u)" != '0' ]; then + update_config_var $ZBX_CONFIG "User" "$(whoami)" + else + update_config_var $ZBX_CONFIG "AllowRoot" "1" + fi } prepare_proxy() { diff --git a/server-mysql/alpine/Dockerfile b/server-mysql/alpine/Dockerfile index 36b1d3fba..02e2107e1 100644 --- a/server-mysql/alpine/Dockerfile +++ b/server-mysql/alpine/Dockerfile @@ -10,9 +10,10 @@ LABEL org.opencontainers.image.title="Zabbix server (MySQL)" \ STOPSIGNAL SIGTERM RUN set -eux && \ - addgroup zabbix && \ + addgroup -S -g 1000 zabbix && \ adduser -S \ -D -G zabbix \ + -u 999 \ -h /var/lib/zabbix/ \ zabbix && \ adduser zabbix dialout && \ diff --git a/server-mysql/alpine/docker-entrypoint.sh b/server-mysql/alpine/docker-entrypoint.sh index 9560099b4..f53fe8e86 100755 --- a/server-mysql/alpine/docker-entrypoint.sh +++ b/server-mysql/alpine/docker-entrypoint.sh @@ -417,6 +417,12 @@ update_zbx_config() { update_config_var $ZBX_CONFIG "TLSCertFile" "${ZBX_TLSCERTFILE}" update_config_var $ZBX_CONFIG "TLSKeyFile" "${ZBX_TLSKEYFILE}" + + if [ "$(id -u)" != '0' ]; then + update_config_var $ZBX_CONFIG "User" "$(whoami)" + else + update_config_var $ZBX_CONFIG "AllowRoot" "1" + fi } prepare_server() { diff --git a/server-pgsql/alpine/Dockerfile b/server-pgsql/alpine/Dockerfile index 3efc7ec32..5a156d2cf 100644 --- a/server-pgsql/alpine/Dockerfile +++ b/server-pgsql/alpine/Dockerfile @@ -10,9 +10,10 @@ LABEL org.opencontainers.image.title="Zabbix server (PostgreSQL)" \ STOPSIGNAL SIGTERM RUN set -eux && \ - addgroup zabbix && \ + addgroup -S -g 1000 zabbix && \ adduser -S \ -D -G zabbix \ + -u 999 \ -h /var/lib/zabbix/ \ zabbix && \ adduser zabbix dialout && \ diff --git a/server-pgsql/alpine/docker-entrypoint.sh b/server-pgsql/alpine/docker-entrypoint.sh index 77943ce8d..3efbe34da 100755 --- a/server-pgsql/alpine/docker-entrypoint.sh +++ b/server-pgsql/alpine/docker-entrypoint.sh @@ -384,6 +384,12 @@ update_zbx_config() { update_config_var $ZBX_CONFIG "TLSCertFile" "${ZBX_TLSCERTFILE}" update_config_var $ZBX_CONFIG "TLSKeyFile" "${ZBX_TLSKEYFILE}" + + if [ "$(id -u)" != '0' ]; then + update_config_var $ZBX_CONFIG "User" "$(whoami)" + else + update_config_var $ZBX_CONFIG "AllowRoot" "1" + fi } prepare_server() { diff --git a/web-apache-mysql/alpine/Dockerfile b/web-apache-mysql/alpine/Dockerfile index 1bcff259b..4e0ecc3d7 100644 --- a/web-apache-mysql/alpine/Dockerfile +++ b/web-apache-mysql/alpine/Dockerfile @@ -10,9 +10,10 @@ LABEL org.opencontainers.image.title="Zabbix web-interface (Apache, MySQL)" \ STOPSIGNAL SIGTERM RUN set -eux && \ - addgroup zabbix && \ + addgroup -S -g 1000 zabbix && \ adduser -S \ -D -G zabbix \ + -u 999 \ -h /var/lib/zabbix/ \ -H \ zabbix && \ diff --git a/web-apache-pgsql/alpine/Dockerfile b/web-apache-pgsql/alpine/Dockerfile index f11eb1830..c3ba11c98 100644 --- a/web-apache-pgsql/alpine/Dockerfile +++ b/web-apache-pgsql/alpine/Dockerfile @@ -10,9 +10,10 @@ LABEL org.opencontainers.image.title="Zabbix web-interface (Apache, PostgreSQL)" STOPSIGNAL SIGTERM RUN set -eux && \ - addgroup zabbix && \ + addgroup -S -g 1000 zabbix && \ adduser -S \ -D -G zabbix \ + -u 999 \ -h /var/lib/zabbix/ \ -H \ zabbix && \