I’m currently using Docker Desktop and I’m encountering an issue with my database. I have been able to use the pgAdmin container without any problems. However, when I attempt to connect the database with the server, I encounter an error.
Unfortunately, I haven’t been able to determine the cause of this issue. I would appreciate any assistance or suggestions on how to resolve this problem. Thank you in advance for your help.
Here is my docker-compose.yml file:
container_name: my-database
- POSTGRES_PASSWORD= 123456
- ./postgres:/var/lib/postgresql/data
- PGADMIN_DEFAULT_PASSWORD= 123456
- ./pgadmin:/var/lib/pgadmin
- ./pgadmin:/certs/server. cert
- ./pgadmin:/certs/server. key
- ./pgadmin:/pgadmin4/servers. json
<code>version: '3'
services:
myDB:
image: postgres:16
container_name: my-database
restart: always
ports:
- 5433:5432
environment:
- POSTGRES_USER=alumno
- POSTGRES_PASSWORD=123456
- POSTGRES_DB=course-db
volumes:
- ./postgres:/var/lib/postgresql/data
pdAdmin:
image: dpage/pgadmin4
container_name: pgadmin4
restart: always
depends_on:
- myDB
ports:
- 8080:80
user: '$UID:$GID'
environment:
- [email protected]
- PGADMIN_DEFAULT_PASSWORD=123456
volumes:
- ./pgadmin:/var/lib/pgadmin
- ./pgadmin:/certs/server.cert
- ./pgadmin:/certs/server.key
- ./pgadmin:/pgadmin4/servers.json
</code>
version: '3'
services:
myDB:
image: postgres:16
container_name: my-database
restart: always
ports:
- 5433:5432
environment:
- POSTGRES_USER=alumno
- POSTGRES_PASSWORD=123456
- POSTGRES_DB=course-db
volumes:
- ./postgres:/var/lib/postgresql/data
pdAdmin:
image: dpage/pgadmin4
container_name: pgadmin4
restart: always
depends_on:
- myDB
ports:
- 8080:80
user: '$UID:$GID'
environment:
- [email protected]
- PGADMIN_DEFAULT_PASSWORD=123456
volumes:
- ./pgadmin:/var/lib/pgadmin
- ./pgadmin:/certs/server.cert
- ./pgadmin:/certs/server.key
- ./pgadmin:/pgadmin4/servers.json
I need to use port 5433 for this connection, as port 5432 is already being used by PostgreSQL on my PC.
Here is the logs of the container:
< code > 2024 - 05 - 18 12 : 17 : 09
2024 - 05 - 18 12 : 17 : 09 PostgreSQL Database directory appears to contain a database; Skipping initialization
2024 - 05 - 18 12 : 17 : 09 2024 - 05 - 18 16 : 17 : 09.672 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 - 05 - 18 12 : 17 : 09 2024 - 05 - 18 16 : 17 : 09.672 UTC [ 1 ] LOG: listening on IPv4 address "0.0.0.0" , port 5432
2024 - 05 - 18 12 : 17 : 09 2024 - 05 - 18 16 : 17 : 09.672 UTC [ 1 ] LOG: listening on IPv6 address "::" , port 5432
2024 - 05 - 18 12 : 17 : 09 2024 - 05 - 18 16 : 17 : 09.685 UTC [ 1 ] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024 - 05 - 18 12 : 17 : 09 2024 - 05 - 18 16 : 17 : 09.698 UTC [ 29 ] LOG: database system was shut down at 2024 - 05 - 18 16 : 16 : 54 UTC
2024 - 05 - 18 12 : 17 : 09 2024 - 05 - 18 16 : 17 : 09.709 UTC [ 1 ] LOG: database system is ready to accept connections
2024 - 05 - 18 12 : 22 : 09 2024 - 05 - 18 16 : 22 : 09.750 UTC [ 27 ] LOG: checkpoint starting: time
2024 - 05 - 18 12 : 22 : 09 2024 - 05 - 18 16 : 22 : 09.804 UTC [ 27 ] LOG: checkpoint complete: wrote 3 buffers ( 0 . 0 % ) ; 0 WAL file ( s ) added, 0 removed, 0 recycled; write= 0.015 s, sync= 0.007 s, total= 0.055 s; sync files= 2 , longest= 0.004 s, average= 0.004 s; distance= 0 kB, estimate= 0 kB; lsn= 0 / 19536E0 , redo lsn= 0 /19536A8
2024 - 05 - 18 12 : 43 : 36 2024 - 05 - 18 16 : 43 : 36.351 UTC [ 91 ] LOG: invalid length of startup packet
2024 - 05 - 18 12 : 43 : 37 2024 - 05 - 18 16 : 43 : 37.483 UTC [ 92 ] LOG: invalid length of startup packet
2024 - 05 - 18 12 : 43 : 38 2024 - 05 - 18 16 : 43 : 38.965 UTC [ 93 ] LOG: invalid length of startup packet
2024 - 05 - 18 12 : 43 : 39 2024 - 05 - 18 16 : 43 : 39.974 UTC [ 94 ] LOG: invalid length of startup packet
<code>2024-05-18 12:17:09
2024-05-18 12:17:09 PostgreSQL Database directory appears to contain a database; Skipping initialization
2024-05-18 12:17:09
2024-05-18 12:17:09 2024-05-18 16:17:09.672 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-05-18 12:17:09 2024-05-18 16:17:09.672 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2024-05-18 12:17:09 2024-05-18 16:17:09.672 UTC [1] LOG: listening on IPv6 address "::", port 5432
2024-05-18 12:17:09 2024-05-18 16:17:09.685 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-05-18 12:17:09 2024-05-18 16:17:09.698 UTC [29] LOG: database system was shut down at 2024-05-18 16:16:54 UTC
2024-05-18 12:17:09 2024-05-18 16:17:09.709 UTC [1] LOG: database system is ready to accept connections
2024-05-18 12:22:09 2024-05-18 16:22:09.750 UTC [27] LOG: checkpoint starting: time
2024-05-18 12:22:09 2024-05-18 16:22:09.804 UTC [27] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.015 s, sync=0.007 s, total=0.055 s; sync files=2, longest=0.004 s, average=0.004 s; distance=0 kB, estimate=0 kB; lsn=0/19536E0, redo lsn=0/19536A8
2024-05-18 12:43:36 2024-05-18 16:43:36.351 UTC [91] LOG: invalid length of startup packet
2024-05-18 12:43:37 2024-05-18 16:43:37.483 UTC [92] LOG: invalid length of startup packet
2024-05-18 12:43:38 2024-05-18 16:43:38.965 UTC [93] LOG: invalid length of startup packet
2024-05-18 12:43:39 2024-05-18 16:43:39.974 UTC [94] LOG: invalid length of startup packet
</code>
2024-05-18 12:17:09
2024-05-18 12:17:09 PostgreSQL Database directory appears to contain a database; Skipping initialization
2024-05-18 12:17:09
2024-05-18 12:17:09 2024-05-18 16:17:09.672 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-05-18 12:17:09 2024-05-18 16:17:09.672 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2024-05-18 12:17:09 2024-05-18 16:17:09.672 UTC [1] LOG: listening on IPv6 address "::", port 5432
2024-05-18 12:17:09 2024-05-18 16:17:09.685 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-05-18 12:17:09 2024-05-18 16:17:09.698 UTC [29] LOG: database system was shut down at 2024-05-18 16:16:54 UTC
2024-05-18 12:17:09 2024-05-18 16:17:09.709 UTC [1] LOG: database system is ready to accept connections
2024-05-18 12:22:09 2024-05-18 16:22:09.750 UTC [27] LOG: checkpoint starting: time
2024-05-18 12:22:09 2024-05-18 16:22:09.804 UTC [27] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.015 s, sync=0.007 s, total=0.055 s; sync files=2, longest=0.004 s, average=0.004 s; distance=0 kB, estimate=0 kB; lsn=0/19536E0, redo lsn=0/19536A8
2024-05-18 12:43:36 2024-05-18 16:43:36.351 UTC [91] LOG: invalid length of startup packet
2024-05-18 12:43:37 2024-05-18 16:43:37.483 UTC [92] LOG: invalid length of startup packet
2024-05-18 12:43:38 2024-05-18 16:43:38.965 UTC [93] LOG: invalid length of startup packet
2024-05-18 12:43:39 2024-05-18 16:43:39.974 UTC [94] LOG: invalid length of startup packet