zabbix / zabbix-docker

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

DB_SERVER_SOCKET doesn't work with postgres based webservers #1577

Open rrauenza opened 2 days ago

rrauenza commented 2 days ago
SUMMARY

DB_SERVER_SOCKET=/var/run/postgresql/.s.PGSQL.5432 is ignored by the postgres based web servers (I've searched the source)

OS / ENVIRONMENT / Used docker-compose files

I've jumped into the docker container for nginx, and it definitely is in the environment:

zabbix@58219e893dcc:/etc$ env | grep DB
DB_SERVER_SOCKET=/var/run/postgresql/.s.PGSQL.5432
DB_SERVER_HOST=localhost
DB_SERVER_PORT=5432
POSTGRES_DB=zabbix

The file also exists:

srwxrwxrwx 1 104 113 0 Nov 30 17:25 /var/run/postgresql/.s.PGSQL.5432
CONFIGURATION
DB_SERVER_SOCKET=/var/run/postgresql/.s.PGSQL.5432
DB_SERVER_HOST=localhost
DB_SERVER_PORT=5432
POSTGRES_DB=zabbix
STEPS TO REPRODUCE
---
services:
  zabbix-server-pgsql:
    image: zabbix/zabbix-server-pgsql:7.0.4-ubuntu
    env_file:
      - .env
    volumes:
      - "/var/run/postgresql/.s.PGSQL.5432:/var/run/postgresql/.s.PGSQL.5432"
    network_mode: host

  zabbix-web-nginx-pgsql:
    image: zabbix/zabbix-web-nginx-pgsql:7.0.4-ubuntu
    env_file:
      - .env
    environment:
      - ZBX_SERVER_HOST=zabbix
      - ZBX_SERVER_NAME=Zabbix
    volumes:
      - "/var/run/postgresql/.s.PGSQL.5432:/var/run/postgresql/.s.PGSQL.5432"
    ports:
      # - 443:8443
      - 8001:80
$ cat .env 
DB_SERVER_HOST=localhost
DB_SERVER_SOCKET=/var/run/postgresql/.s.PGSQL.5432
POSTGRES_DB=zabbix
POSTGRES_USER=zabbix
POSTGRES_PASSWORD=zabbix
DB_SERVER_PORT=5432
DEBUG_MODE=false
PHP_TZ=America/Los_Angeles
ZBX_STARTPINGERS=10
EXPECTED RESULTS

webserver should connect to postgres

ACTUAL RESULTS
zabbix-web-nginx-pgsql-1  | **** PostgreSQL server is not available. Waiting 5 seconds...
zabbix-web-nginx-pgsql-1  | **** PostgreSQL server is not available. Waiting 5 seconds...
zabbix-web-nginx-pgsql-1  | **** PostgreSQL server is not available. Waiting 5 seconds...
zabbix-web-nginx-pgsql-1  | **** PostgreSQL server is not available. Waiting 5 seconds...
zabbix-web-nginx-pgsql-1  | **** PostgreSQL server is not available. Waiting 5 seconds...
zabbix-web-nginx-pgsql-1  | **** PostgreSQL server is not available. Waiting 5 seconds...
zabbix-web-nginx-pgsql-1  | **** PostgreSQL server is not available. Waiting 5 seconds...
zabbix-web-nginx-pgsql-1  | **** PostgreSQL server is not available. Waiting 5 seconds...
zabbix-web-nginx-pgsql-1  | **** PostgreSQL server is not available. Waiting 5 seconds...

zabbix-server-pgsql connects succesfully.

rrauenza commented 2 days ago

Similar to https://github.com/zabbix/zabbix-docker/issues/1074 for mysql case