Olá, estou enfrentando um problema de inicialização do meu banco de dados. Meu código de teste é este:
version: '3.8'
services:
bancoDeDados:
image: postgres:latest
container_name: meuBanco
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: teste
ports:
- "5433:5432"
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data:
Os logs quando inicializa o docker é este:
anderson@anderson:~/Área de Trabalho/posgraduacao/tech/postgress$ docker compose up
[+] Building 0.0s (0/0) docker:default
WARN[0000] Found orphan containers ([meu_postgres]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
[+] Running 1/0
✔ Container meuBanco Created 0.0s
Attaching to meuBanco
meuBanco |
meuBanco | PostgreSQL Database directory appears to contain a database; Skipping initialization
meuBanco |
meuBanco | 2024-06-25 00:15:06.549 UTC [1] LOG: starting PostgreSQL 16.3 (Debian 16.3-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
meuBanco | 2024-06-25 00:15:06.549 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
meuBanco | 2024-06-25 00:15:06.549 UTC [1] LOG: listening on IPv6 address "::", port 5432
meuBanco | 2024-06-25 00:15:06.550 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
meuBanco | 2024-06-25 00:15:06.553 UTC [29] LOG: database system was shut down at 2024-06-25 00:15:02 UTC
meuBanco | 2024-06-25 00:15:06.556 UTC [1] LOG: database system is ready to accept connections
Quando eu peço para o docker me mostrar os logs do container eu obtenho está resposta:
anderson@anderson:~/Área de Trabalho/posgraduacao/tech/postgress$ docker logs 11d85b62284c
PostgreSQL Database directory appears to contain a database; Skipping initialization
2024-06-25 00:09:51.465 UTC [1] LOG: starting PostgreSQL 16.3 (Debian 16.3-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2024-06-25 00:09:51.465 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2024-06-25 00:09:51.465 UTC [1] LOG: listening on IPv6 address "::", port 5432
2024-06-25 00:09:51.467 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-06-25 00:09:51.470 UTC [29] LOG: database system was shut down at 2024-06-25 00:09:42 UTC
2024-06-25 00:09:51.475 UTC [1] LOG: database system is ready to accept connections
2024-06-25 00:14:51.568 UTC [27] LOG: checkpoint starting: time
2024-06-25 00:14:51.659 UTC [27] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.001 s, total=0.091 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/1953508, redo lsn=0/19534D0
2024-06-25 00:15:02.632 UTC [1] LOG: received fast shutdown request
2024-06-25 00:15:02.632 UTC [1] LOG: aborting any active transactions
2024-06-25 00:15:02.634 UTC [1] LOG: background worker "logical replication launcher" (PID 32) exited with exit code 1
2024-06-25 00:15:02.635 UTC [27] LOG: shutting down
2024-06-25 00:15:02.636 UTC [27] LOG: checkpoint starting: shutdown immediate
2024-06-25 00:15:02.638 UTC [27] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.003 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=0 kB; lsn=0/19535B8, redo lsn=0/19535B8
2024-06-25 00:15:02.643 UTC [1] LOG: database system is shut down
PostgreSQL Database directory appears to contain a database; Skipping initialization
2024-06-25 00:15:06.549 UTC [1] LOG: starting PostgreSQL 16.3 (Debian 16.3-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2024-06-25 00:15:06.549 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2024-06-25 00:15:06.549 UTC [1] LOG: listening on IPv6 address "::", port 5432
2024-06-25 00:15:06.550 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-06-25 00:15:06.553 UTC [29] LOG: database system was shut down at 2024-06-25 00:15:02 UTC
2024-06-25 00:15:06.556 UTC [1] LOG: database system is ready to accept connections
2024-06-25 00:20:06.637 UTC [27] LOG: checkpoint starting: time
2024-06-25 00:20:06.651 UTC [27] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.001 s, total=0.014 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/19536A0, redo lsn=0/1953668
Ele não cria login nem senha, e não consigo me conectar a ele, nem definir um login e senha de usuário, alguém pode me ajudar?