I am running a Postgres image using docker. It used to run without any problems on both Windows10 and Ubuntu 18.04.
After recloning the project on the Ubuntu system, it gives me password authentication failed for user "postgres"
error after running docker-compose up
.
It used to run without any problems before recloning the project on the Ubuntu system and it still works without any problems on the Windows10 system.
My docker-compose.yml
:
version: '2'
services:
postgresql:
image: 'bitnami/postgresql:latest'
ports:
- '5432:5432'
environment:
- POSTGRESQL_USERNAME=someuser
- POSTGRESQL_PASSWORD=mysecretpassword
- POSTGRESQL_DATABASE=mydatabase
I tried sudo docker system prune
to remove all stopped containers and their unused networks. This does not solve the problem.
What do I need to change/do so the Postgres image is able to run succesfully on the Ubuntu system again?
The full error:
postgresql_1 | nami INFO Initializing postgresql
postgresql_1 | postgre INFO ==> No injected postgresql.conf file found.
Creating default postgresql.conf file...
postgresql_1 | postgre INFO ==> No injected pg_hba.conf file found. Creating default pg_hba.conf file...
postgresql_1 | postgre INFO ==> Deploying PostgreSQL from scratch...
postgresql_1 | postgre INFO ==> Creating database mydatabase...
postgresql_1 | postgre INFO ==> Creating user "someuser"...
postgresql_1 | postgre INFO ==> Granting access to "someuser" to the database mydatabase...
postgresql_1 | postgre INFO ==> Configuring PostgreSQL...
postgresql_1 | postgre INFO ==> Configuring replication parameters...
postgresql_1 | postgre INFO ==> Configuring permissions for config files...
postgresql_1 | postgre INFO
postgresql_1 | postgre INFO
########################################################################
postgresql_1 | postgre INFO Installation parameters for postgresql:
postgresql_1 | postgre INFO User: someuser
postgresql_1 | postgre INFO Password: ***************
postgresql_1 | postgre INFO Database: mydatabase
postgresql_1 | postgre INFO (Passwords are not shown for security reasons)
postgresql_1 | postgre INFO
########################################################################
postgresql_1 | postgre INFO
postgresql_1 | nami INFO postgresql successfully initialized
postgresql_1 | INFO ==> Starting postgresql...
postgresql_1 | 2019-04-15 09:31:18.582 GMT [125] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgresql_1 | 2019-04-15 09:31:18.583 GMT [125] LOG: listening on IPv6 address "::", port 5432
postgresql_1 | 2019-04-15 09:31:18.587 GMT [125] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
postgresql_1 | 2019-04-15 09:31:18.599 GMT [132] LOG: database system was shut down at 2019-04-15 09:31:18 GMT
postgresql_1 | 2019-04-15 09:31:18.603 GMT [125] LOG: database system is ready to accept connections
postgresql_1 | 2019-04-15 09:31:24.414 GMT [139] FATAL: password authentication failed for user "postgres"
postgresql_1 | 2019-04-15 09:31:24.414 GMT [139] DETAIL: User "postgres" has no password assigned.
postgresql_1 | Connection matched pg_hba.conf line 95: "host all all 0.0.0.0/0 md5"
postgresql_1 | 2019-04-15 09:31:27.492 GMT [140] FATAL: password authentication failed for user "postgres"
postgresql_1 | 2019-04-15 09:31:27.492 GMT [140] DETAIL: User "postgres" has no password assigned.
linux - PostgreSQL: Remove password requirement for user postgres - Database Administrators Stack Exchange I understand that, upon installation, PostgreSQL has no password for its db root user (postgres): postgres=# select usename, passwd is null from pg_shadow; usename | ?column?
RUN /etc/init.d/postgresql start && psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" && createdb -O docker docker # Adjust PostgreSQL configuration so that remote connections to the # database are possible.
If pg_hba.conftells PostgreSQL to ask for a password but there's none set, then all login attempts will fail no matter what password is supplied. Share Improve this answer Follow answered Nov 21, 2014 at 2:05
The postgres user by default has no password. To remove a user password (in this case for the postgres user/role): alter role postgres password null; We also need to set authentication to trustin pg_hba.conf- view details
If you check the documentation of the docker image (https://hub.docker.com/r/bitnami/postgresql) it says that when you set POSTGRESQL_USERNAME
the postgres user won't have a password assigned and you won't be able to use it to login to the db.
Use the user that you specified.
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