I am trying to raise a service in my docker-compose to use postgres, I can raise the container correctly, the problem is that it does not allow me to authenticate with the password that I am setting in the environment variables
this is my docker-compose service:
version: "3"
services:
api:
build:
context: .
dockerfile: docker/nodejs/Dockerfile
ports:
- "3000:3000"
volumes:
- .:/app
links:
- postgresql
postgresql:
image: postgres:11-alpine
restart: always
environment:
POSTGRES_PASSWORD: 00000000
volumes:
- ~/docker/postgresql:/var/lib/postgresql/data
ports:
- "5432:5432"
what can be the problem here? i trying to get in with pgadmin. In the console show me the error:
password authentication failed for user "postgres"
Password does not match for user "postgres".
The Postgres password is set on the first initialization if the db (when the var/lib/postgresql/data folder is empty). Since you probably ran docker-compose before with a different password, the new one will not take effect. To fix this, remove the volume in your host machine and have docker-compose automatically recreate it next time you run docker-compose up. Note that removing this volume will delete all data stored in PostgreSQL
Another way to fail with POSTGRES_PASSWORD is to set a password with forbidden characters. You won't get any warnings, but you won't be able to login with this password.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With