I am creating two databases: product, and test one:
version: '3.8'
services:
db:
image: postgres:13-alpine
environment:
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
POSTGRES_DB: mydb
volumes:
- postgres_test_data:/var/lib/postgresql/data
- ./db/create_script.sql:/docker-entrypoint-initdb.d/create_script.sql
ports:
- "5432:5432"
test-db:
image: postgres:13-alpine
environment:
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
POSTGRES_DB: mydb
volumes:
- postgres_test_data:/var/lib/postgresql/data
- ./db/create_script.sql:/docker-entrypoint-initdb.d/create_script.sql
ports:
- "5433:5432"
volumes:
postgres_prod_data:
postgres_test_data:
This docker compose works, it created images, started containers.
However i when i try to conncet to db
image, it says invalid credentials, HOWEVER when i try to connect to test-db
which is literally copy paste with changed port, it WORKS.
What is causing this? These images are newly created, with new volumes and literally copy paste of each others, how come one works and one not?
Logs do not specify any error for neither of them.
Thanks for help