-
Notifications
You must be signed in to change notification settings - Fork 379
Add PostgreSQL Container
ucan-lab edited this page May 11, 2021
·
7 revisions
volumes:
db-store:
services:
db:
image: postgres:13
ports:
- target: 5432
published: ${DB_PORT:-5432}
protocol: tcp
mode: host
volumes:
- type: volume
source: db-store
target: /var/lib/postgresql/data
volume:
nocopy: true
environment:
- POSTGRES_DB=${DB_NAME:-laravel_local}
- POSTGRES_USER=${DB_USER:-phper}
- POSTGRES_PASSWORD=${DB_PASS:-secret}
- PGPASSWORD=${DB_PASS:-secret}
- TZ=UTC
$ docker compose exec app bash
$ php artisan migrate
$ docker compose exec db bash
$ psql -U $POSTGRES_USER $POSTGRES_DB
=# SELECT character_set_name FROM information_schema.character_sets;
character_set_name
--------------------
UTF8
(1 row)
=# SHOW timezone;
TimeZone
----------
UTC
(1 row)
=# \d
List of relations
Schema | Name | Type | Owner
--------+--------------------+----------+-------
public | failed_jobs | table | phper
public | failed_jobs_id_seq | sequence | phper
public | migrations | table | phper
public | migrations_id_seq | sequence | phper
public | password_resets | table | phper
public | users | table | phper
public | users_id_seq | sequence | phper
(7 rows)
psql:
docker compose exec db bash -c 'psql -U $$POSTGRES_USER $$POSTGRES_DB'
$ make psql