I'm using Bitbucket pipeline with PosgreSQL for CI/CD. According to this documentation PostgreSQL service has been described in bitbucket-pipelines.yml
this way:
definitions:
services:
postgres:
image: postgres:9.6-alpine
It worked just fine until now. But all my latest pipelines failed with following error:
Error: Database is uninitialized and superuser password is not specified.
You must specify POSTGRES_PASSWORD for the superuser. Use
"-e POSTGRES_PASSWORD=password" to set it in "docker run".
You may also use POSTGRES_HOST_AUTH_METHOD=trust to allow all connections
without a password. This is *not* recommended. See PostgreSQL
documentation about "trust":
https://www.postgresql.org/docs/current/auth-trust.html
How can I fix it? There was no changes in bitbucket-pipelines.yml
file which could be the reason of such error..
Looks like the reason is docker image's updates (github issue). Latest versions do not allow to connect to DB without a password from anywhere. So you need to specify username/password:
definitions:
services:
postgres:
image: postgres:9.6-alpine
environment:
POSTGRES_DB: pipelines
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_user_password
Or if you still don't want to use password, you can just set POSTGRES_HOST_AUTH_METHOD=trust
environment variable:
definitions:
services:
postgres:
image: postgres:9.6-alpine
environment:
POSTGRES_HOST_AUTH_METHOD: trust
This is a very recent change, as of about a week ago. One way to avoid it is to hardcode your postgres version to not the latest, eg changing to postgres:9.5.18
or postgres:9.5.20-alpine
Another way is to pass a fake password:
services:
db:
image: postgres
ports:
- "8001:5432"
environment:
- POSTGRES_PASSWORD=fake_password
See the discussion here: https://github.com/docker-library/postgres/issues/681
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