Answer the question
In order to leave comments, you need to log in
Why does the Docker container not see PostgreSQL?
One container should use aiopg to create a table and add data to it. The container with docker-compose and the program that adds the data is described as follows:
PS file is shortened so that it is not too cumbersome. The part that gives errors is shown.
version: "3.9"
services:
db:
image: postgres:13
volumes:
- ./data/db:/var/lib/postgresql/data
environment:
- POSTGRES_DB=drama
- POSTGRES_USER=drama_user
- POSTGRES_PASSWORD=pass
ports:
- "5432:5432"
dramatiq:
build:
context: ./
dockerfile: ./dramatiq/Dockerfile
depends_on:
- redis
- db
connection = await aiopg.connect(database="drama", user="drama_user", password="pass", host="db")
cursor = await connection.cursor()
dramatiq_1 | File "/usr/local/lib/python3.9/site-packages/aiopg/connection.py", line 788, in _ready
dramatiq_1 | state = self._conn.poll()
dramatiq_1 | psycopg2.OperationalError: could not connect to server: Connection refused
dramatiq_1 | Is the server running on host "db" (172.29.0.3) and accepting
dramatiq_1 | TCP/IP connections on port 5432?
Answer the question
In order to leave comments, you need to log in
With what such error can be connected?
To access through db, you need to combine containers into one network
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question