docker-compose up
docker-compose -f ./postgresql/docker-compose.yml up
- Go to
https://localhost:8080
to access Adminer portal. - Enter respective credentials after selecting system as
PostgreSQL
and hit login - You are connected to postgresql GUI and good to go now!
Run the following command and hit enter to know version of the PostgreSQL:
docker-compose -f postgresql/docker-compose.yml run db psql -U chaiaurcode -p 5432 -h db -d chaiDB -c "SELECT version();"
-
-f postgresql/docker-compose.yml
: points to the file which we want to run docker compose on. If we havedocker-compose.yml
in root folder we don't need to pass this flag. -
run db
: Runs a one-time command in thedb
service defined in the Docker Compose file. -
psql
: Initiates the PostgreSQL command-line client. -
-U chaiaurcode
: Specifies the PostgreSQL username aschaiaurcode
. -
-p 5432
: Specifies the port number (5432) on which the PostgreSQL server is running. If the port is5432
then this flag is optional. -
-h db
: Specifies the host asdb
where the PostgreSQL server is located. -
-d chaiDB
: Specifies the name of the PostgreSQL database aschaiDB
. -
-c "SELECT version();"
: Executes the SQL commandSELECT version();
on the specified database.
Running this command will prompt you to enter the password. Enter POSTGRES_PASSWORD
env var value from docker compose file. And, you are good to go!
Output after correct password:
version
---------------------------------------------------------------------------------------------------------------------------
PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
(1 row)
Now, you can run postgresql related commands here.