Docker Community Forums

Share and learn in the Docker community.

Compose unable to connect to remote PostgreSQL server

Hello everyone, that’s my first post here and I’m very new to Docker as well. I’m facing an issue with my compose setup for a long time from now:

I have two different hosts (both in LAN):

1 - Ubuntu 18.04 LTS with PostgreSQL/TimescaleDB dedicated server.
2 - Ubuntu 18.04 LTS with a docker-compose setup.

The problem:

The application that I’m trying to deploy from container is a Zabbix server. I can’t make the container connect to the database when I use the command:

docker-compose -f docker-compose.yml up -d

Container logs -> https://pastebin.com/NZSvQyVn

If I connect inside the Zabbix server container (which was deployed via compose), and try to connect to the PostgreSQL server using the “psql” command it works without problems. By that, I obviously can ping and telnet without any problem!

Connection from inside the container -> https://pastebin.com/pdmFMzkk

But the strange thing is: if I deploy the same image, with the same configurations using docker run there’s no connection problem at all:


(the fact the database already exists is irrelevant, the print only proves that the connection was successful)

What I have already done:

  • -Configured PostgreSQL to accept any remote connection.

  • -Tried to test different network types (bridge, host and overlay).

  • -Tried to use a different docker image.

  • -Tried to use env files, secrets and hardcoded envs on the docker-compose file.

  • -Changed the docker-compose file version.

I can’t post my compose file and envs because I’m a new user…

I really don’t know what to test anymore… I really appreciate any help here! Thank y’all.