services:
postgres:
container_name: postgres-sql-wac
image: postgres:14.11
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 1
PGDATA: /var/lib/postgresql/data
POSTGRES_DB: telegram-clone
volumes:
- postgres:/data/postgres
ports:
- 5432:5432
networks:
- telegram-clone
restart: unless-stopped
keycloak:
container_name: keycloak-wac
image: quay.io/keycloak/keycloak:26.0.0
ports:
- 9090:8080
environment:
KC_ADMIN: admin
KC_ADMIN_PASSWORD: admin
networks:
- telegram-clone
command:
- "start-dev"
networks:
telegram-clone:
driver: bridge
volumes:
postgres:
driver: local
keycloak:
driver: local
When I test the connection of data source in intellij it says database does not exist
I also tried to check using the terminal
psql -h localhost -p 5432 -U postgres
postgres=# \l
empty
Here are the logs
2025-04-14T18:15:15.393821048Z The files belonging to this database system will be owned by user "postgres".
2025-04-14T18:15:15.393880153Z This user must also own the server process.
2025-04-14T18:15:15.393890054Z
2025-04-14T18:15:15.393896654Z The database cluster will be initialized with locale "en_US.utf8".
2025-04-14T18:15:15.393902555Z The default database encoding has accordingly been set to "UTF8".
2025-04-14T18:15:15.393908355Z The default text search configuration will be set to "english".
2025-04-14T18:15:15.393913356Z
2025-04-14T18:15:15.393918156Z Data page checksums are disabled.
2025-04-14T18:15:15.394089971Z
2025-04-14T18:15:15.394114474Z fixing permissions on existing directory /var/lib/postgresql/data ... ok
2025-04-14T18:15:15.395597706Z creating subdirectories ... ok
2025-04-14T18:15:15.395799624Z selecting dynamic shared memory implementation ... posix
2025-04-14T18:15:15.420831451Z selecting default max_connections ... 100
2025-04-14T18:15:15.446511235Z selecting default shared_buffers ... 128MB
2025-04-14T18:15:15.463496546Z selecting default time zone ... Etc/UTC
2025-04-14T18:15:15.464558841Z creating configuration files ... ok
2025-04-14T18:15:15.654182111Z running bootstrap script ... ok
2025-04-14T18:15:16.232172833Z performing post-bootstrap initialization ... ok
2025-04-14T18:15:17.770215669Z initdb: warning: enabling "trust" authentication for local connections
2025-04-14T18:15:17.770278374Z You can change this by editing pg_hba.conf or using the option -A, or
2025-04-14T18:15:17.770290575Z --auth-local and --auth-host, the next time you run initdb.
2025-04-14T18:15:17.770215469Z syncing data to disk ... ok
2025-04-14T18:15:17.770313077Z
2025-04-14T18:15:17.770320578Z
2025-04-14T18:15:17.770324878Z Success. You can now start the database server using:
2025-04-14T18:15:17.770329079Z
2025-04-14T18:15:17.770333279Z pg_ctl -D /var/lib/postgresql/data -l logfile start
2025-04-14T18:15:17.770337579Z
2025-04-14T18:15:17.852192762Z waiting for server to start....2025-04-14 18:15:17.851 UTC [48] LOG: starting PostgreSQL 14.11 (Debian 14.11-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2025-04-14T18:15:17.880909017Z 2025-04-14 18:15:17.880 UTC [48] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-04-14T18:15:17.914537709Z 2025-04-14 18:15:17.914 UTC [49] LOG: database system was shut down at 2025-04-14 18:15:16 UTC
2025-04-14T18:15:17.930607838Z 2025-04-14 18:15:17.930 UTC [48] LOG: database system is ready to accept connections
2025-04-14T18:15:18.007568385Z done
2025-04-14T18:15:18.007602088Z server started
2025-04-14T18:15:18.679051225Z CREATE DATABASE
2025-04-14T18:15:18.680313137Z
2025-04-14T18:15:18.680359242Z
2025-04-14T18:15:18.680365242Z /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
2025-04-14T18:15:18.680379543Z
2025-04-14T18:15:18.681691160Z 2025-04-14 18:15:18.681 UTC [48] LOG: received fast shutdown request
2025-04-14T18:15:18.689794981Z waiting for server to shut down....2025-04-14 18:15:18.689 UTC [48] LOG: aborting any active transactions
2025-04-14T18:15:18.692101086Z 2025-04-14 18:15:18.691 UTC [48] LOG: background worker "logical replication launcher" (PID 55) exited with exit code 1
2025-04-14T18:15:18.692130889Z 2025-04-14 18:15:18.692 UTC [50] LOG: shutting down
2025-04-14T18:15:18.771768674Z 2025-04-14 18:15:18.771 UTC [48] LOG: database system is shut down
2025-04-14T18:15:18.781986683Z done
2025-04-14T18:15:18.782016786Z server stopped
2025-04-14T18:15:18.783550322Z
2025-04-14T18:15:18.783579425Z PostgreSQL init process complete; ready for start up.
2025-04-14T18:15:18.783585325Z
2025-04-14T18:15:18.826171414Z 2025-04-14 18:15:18.825 UTC [1] LOG: starting PostgreSQL 14.11 (Debian 14.11-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2025-04-14T18:15:18.826320427Z 2025-04-14 18:15:18.826 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2025-04-14T18:15:18.826339829Z 2025-04-14 18:15:18.826 UTC [1] LOG: listening on IPv6 address "::", port 5432
2025-04-14T18:15:18.839379889Z 2025-04-14 18:15:18.839 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-04-14T18:15:18.859732500Z 2025-04-14 18:15:18.859 UTC [63] LOG: database system was shut down at 2025-04-14 18:15:18 UTC
2025-04-14T18:15:18.880121114Z 2025-04-14 18:15:18.879 UTC [1] LOG: database system is ready to accept connections
Here it shows that database system is ready to accept connections which means that the database has been created and its active.