Skip to content

Can't connect to postgres inside custom docker network. #6

@uliss3s

Description

@uliss3s

I have a ckan docker compose setup running on a specific docker network. Ex.: ckan_network

I changed the docker-compose.yml from the datapusher-plus-docker to use this network and updated the env variables accordingly.

version: "3"

volumes:
  pg_data:

services:
  datapusher:
    container_name: datapusher-plus
    build:
      context: ./datapusher-plus/0.11.0/
      dockerfile: Dockerfile
#    network_mode: "host"
    networks:
      - ckan_network
#    ports:
#      - "8800:8800"
    restart: unless-stopped
    environment:
      - SQLALCHEMY_DATABASE_URI=postgresql://datapusher_jobs:*****@db:5432/datapusher_jobs
      - WRITE_ENGINE_URL=postgresql://datapusher:*****@db:5432/datastore

networks:
  ckan_network:
    external: true

db is the postgres instance.
Running some commands inside de datapusher container:

  • db host it's responding to PING;
  • Connecting with postgres client on db host works;

But the datapusher-plus container throw errors trying to connect to "localhost".

Error

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
datapusher-plus  | 	Is the server running on that host and accepting TCP/IP connections?
datapusher-plus  | connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
datapusher-plus  | 	Is the server running on that host and accepting TCP/IP connections?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions