How to install PostgreSQL with docker and connect to Universal Database Tool (dBeaver) ?
for using docker, you need to install docker desktop in your local computer See installation. Next successfully install docker, please create file docker compose with name docker-compose.yaml
update it with following content:
version: '3.9'
services:
postgres:
image: postgres:14-alpine # this image is for postgres version 14, if change version, please change here postgres:version (https://hub.docker.com/_/postgres)
container_name: postgreSQLv14 # container name
restart: always # always restart
environment:
- POSTGRES_USER=postgres # username for database
- POSTGRES_PASSWORD=postgres # password for database
- POSTGRES_DB=my_db # name of database
ports:
- 5432:5432 # host port 5432 is mapper to docker port 5432
volumes:
- postgres-db-volume:/var/lib/postgresql/data
volumes:
postgres-db-volume:
driver: local
driver_opts:
type: none
o: bind
device: ./data
next steep running docker compose, please use following command:
docker-compose up -d
check your docker container status in docker desktop:
Connect to Database Tool
This project is using Universal Database Tool (dBeaver community) to connect to PostgreSQL. Please install dBeaver in your local computer See installation. Open dBeaver and click on New Databases Connection
tab, and top up form database connection select PostgreSQL
and click next button.
enter connection details and click test connection button.
if test connection success, you can connect to database tool.
click on OK
button and click on Finish
button, you can connect to database tool. Right click the connection that has been created, then click on connect and the database tool will connect
Good luck and have fun. Enjoy your code.