Connecting to Postgresql with laradock in a docker

134 Views Asked by At

I have Postgresql on a server in a docker container. How can I connect to a database gui like tableplus so that i can run php artisan migrate, im also using laravel and how can i retrieve the database credentials of it, i tried the docker ps and this shows up

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2f68a5d257ee laradock_postgres "docker-entrypoint.s…" About an hour ago Up About an hour 0.0.0.0:5432->5432/tcp laradock_postgres_1

1

There are 1 best solutions below

0
jmvcollaborator On

You need to set in .env the host to point the container name.

keep the container up and running retrieve the postgres container name and .env should look:

DB_CONNECTION=pgsql
DB_HOST=postgres (or whatever value is the volume name in docker-compose.yml)
DB_PORT=5432
DB_DATABASE=testdb
DB_USERNAME=root 
DB_PASSWORD=root 

Then you can interactively bash the container init the db and run migrations.