You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

创建zabbix-web-nginx-pgsql容器遇PostgreSQL连接失败问题求助

Fixing "PostgreSQL server is not available" for Zabbix Web Nginx-PG Container

Hey there! As a Docker newbie, it's totally normal to run into this kind of dependency issue—let me walk you through what's wrong and how to fix it step by step.

Why You're Seeing This Error

The zabbix/zabbix-web-nginx-pgsql:latest image is only the Zabbix web frontend paired with Nginx—it does NOT include a PostgreSQL database server. When you start this container, it immediately tries to connect to a PostgreSQL instance, but since you haven't set one up (or linked it to the web container), it keeps waiting indefinitely with that "PostgreSQL server is not available" message.

Your attempt to set DB_SERVER_ROOT_USER="zabbix" didn't work because this variable only matters if the container can already reach a PostgreSQL server (it's used for auto-initializing the Zabbix database/user if needed). Without a running PG server, that variable is irrelevant.

Step-by-Step Fix

To get the Zabbix web frontend working, you need a running PostgreSQL instance (either a Docker container or external server) and a way for the web container to communicate with it. Here's the proper workflow:

1. Create a Docker Network (for Container Communication)

First, create a dedicated network so your Zabbix containers can talk to each other easily using container names:

docker network create zabbix-net

2. Start the PostgreSQL Container

Run a PostgreSQL container with environment variables tailored for Zabbix:

docker run -d \
  --name zabbix-pgsql \
  --network zabbix-net \
  -e POSTGRES_USER=zabbix \
  -e POSTGRES_PASSWORD=zabbix \
  -e POSTGRES_DB=zabbix \
  -e TZ=UTC \ # Adjust this to your local timezone if needed
  postgres:15 # Use a PostgreSQL version compatible with latest Zabbix (15 is a safe choice)

Wait 30-60 seconds for PostgreSQL to fully initialize before moving on.

3. Launch the Zabbix Web Nginx-PG Container

Now start the web container, configuring it to connect to your new PostgreSQL container:

docker run -d \
  --name zabbix-web-nginx-pgsql \
  --network zabbix-net \
  -e DB_SERVER_HOST="zabbix-pgsql" \ # Matches the PG container name from step 2
  -e DB_SERVER_USER="zabbix" \
  -e DB_SERVER_PASSWORD="zabbix" \
  -e DB_NAME="zabbix" \
  -e ZABBIX_SERVER_HOST="zabbix-server" \ # You'll need a Zabbix Server container later for full functionality
  -p 8080:80 \ # Map host port 8080 to the container's web port 80
  zabbix/zabbix-web-nginx-pgsql:latest

4. Verify the Connection

Check the web container logs to confirm it connects to PostgreSQL successfully:

docker logs zabbix-web-nginx-pgsql

You should see messages indicating the frontend is deployed and connected to the database (note: you’ll still need to set up a Zabbix Server container to get full monitoring functionality, but this fixes the PostgreSQL waiting issue).

If Using an External PostgreSQL Server

If you have a PG server running outside Docker, replace DB_SERVER_HOST="zabbix-pgsql" with the IP/hostname of your external server. Also ensure:

  • The external server allows connections from your Docker host’s IP
  • A zabbix database and user exist (with the correct password)
  • The Zabbix schema has been initialized (you can use the zabbix-server-pgsql container to run migrations if needed)

内容的提问来源于stack exchange,提问作者pete

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:08:04