2
respostas

Erro Docker-Compose

Olá! Estou tendo dificuldades para avançar com o comando do docker compose. Sempre que rodo ele, me retorna um erro quanto a senha.

Meu docker-compose.yml:

version: '3'

services:
  database:
    image: postgres
    environment:
      POSTGRES_PASSWORD:
      POSTGRES_DB: clines
    volumes:
      - db-volume:/var/lib/postgresql/data

  api:
    image: caelum/clines-api
    environment:
      DB_HOST: database
    ports:
      - "8080:8080"
volumes:
  db-volume:

Erros:

clines-api-api-1       | SQL State  : 28P01
clines-api-api-1       | Error Code : 0
clines-api-api-1       | Message    : FATAL: password authentication failed for user "postgres"
clines-api-api-1       | Caused by: org.flywaydb.core.internal.exception.FlywaySqlException:
clines-api-api-1       | Unable to obtain connection from database: FATAL: password authentication failed for user "postgres"
clines-api-api-1       | Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres"
clines-api-api-1       |        at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:525) ~[postgresql-42.2.11.jar!/:42.2.11]
clines-api-api-1       |        at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:146) ~[postgresql-42.2.11.jar!/:42.2.11]
clines-api-api-1       |        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:197) ~[postgresql-42.2.11.jar!/:42.2.11]
clines-api-api-1       |        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.11.jar!/:42.2.11]
clines-api-api-1       |        at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:211) ~[postgresql-42.2.11.jar!/:42.2.11]
clines-api-api-1       |        at org.postgresql.Driver.makeConnection(Driver.java:459) ~[postgresql-42.2.11.jar!/:42.2.11]
clines-api-api-1       |        at org.postgresql.Driver.connect(Driver.java:261) ~[postgresql-42.2.11.jar!/:42.2.11]
clines-api-api-1       |        at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.2.jar!/:na]
clines-api-api-1       |        at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354) ~[HikariCP-3.4.2.jar!/:na]
clines-api-api-1       |        at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202) ~[HikariCP-3.4.2.jar!/:na]
clines-api-api-1       |        at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473) ~[HikariCP-3.4.2.jar!/:na]
clines-api-api-1       |        at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554) ~[HikariCP-3.4.2.jar!/:na]
clines-api-api-1       |        at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-3.4.2.jar!/:na]
clines-api-api-1       |        at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-3.4.2.jar!/:na]
clines-api-api-1       |        at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:56) ~[flyway-core-6.0.8.jar!/:na]
clines-api-api-1       |        ... 32 common frames omitted4

Já configurei o pg_hba.config para que não seja necessário senha, mas mesmo assim o erro persiste. Poderiam me ajudar? Obg

2 respostas

Você deve POSTGRES_HOST_AUTH_METHOD=trust usar isto para estabelecer conexões sem senha.

Exemplo: docker run -d -i --name postgres -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres:9.6.23

Veja a documentação em : https://www.postgresql.org/docs/current/auth-trust.htm

Tentei rodar o comando que sugeriu e, em seguida, o "docker-compose up", mas segue retornando o mesmo erro.