Django не получает доступ к базе данных PostgreSQL с помощью Docker
Вот сообщение об ошибке:
Got an error checking a consistent migration history performed for database connection 'default': connection failed: could not receive data from server: No route to host
Вот моя .env
POSTGRES_DB=ibm_skiller
POSTGRES_PASSWORD=mYP@sSw0rd
POSTGRES_USER=ibm_skiller
POSTGRES_HOST=172.19.0.2
POSTGRES_PORT=5432
Вот мой docker-compose.yml:
postgres:
container_name: postgres
env_file:
- ./.env
image: postgres:alpine3.19
ports:
- 5432:5432
volumes:
- postgres16:/var/lib/postgresql/data
# - ./ibm_skiller_init.sql:/docker-entrypoint-initdb.d/ibm_skiller_init.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ibm_skiller"]
interval: 5s
timeout: 5s
retries: 5
networks:
- skillernet
Вот вывод команды docker ps
:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a2d40d97e3f0 postgres:alpine3.19 "docker-entrypoint.s…" 3 hours ago Up 3 hours (healthy) 0.0.0.0:5432->5432/tcp postgres
f86b9bacd25e bd43f03c087b "./entrypoint.sh" 5 hours ago Up 5 hours 0.0.0.0:8000->8000/tcp, 0.0.0.0:9000->80/tcp skiller