· 6 years ago · Mar 17, 2019, 08:22 PM
1version:Â "3"
2services:
3Â Â web:
4Â Â Â Â build:Â .
5Â Â Â Â volumes:
6Â Â Â Â Â Â -Â ./:/usr/src/app/
7Â Â Â Â Â Â -Â /usr/src/app/node_modules
8Â Â Â Â ports:
9      - “3000:3000â€
10Â Â Â Â depends_on:
11Â Â Â Â Â Â -Â postgres
12Â Â postgres:
13Â Â Â Â container_name:Â postgres
14Â Â Â Â build:
15Â Â Â Â Â Â context:Â .
16Â Â Â Â Â Â dockerfile:Â pgDockerfile
17Â Â Â Â environment:
18Â Â Â Â Â Â POSTGRES_PASSWORD:Â test
19Â Â Â Â Â Â POSTGRES_USER: test
20Â Â Â Â ports:
21Â Â Â Â Â Â -Â 5432:5432
22
23FROM postgres:9.6-alpine
24
25# copy init sql
26ADD 00-initial.sql /docker-entrypoint-initdb.d/
27
28CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
29CREATE TABLE IF NOT EXISTS test (
30    id text NOT NULL,
31    title varchar(200) NOT NULL
32);
33
34postgres | CREATE DATABASE
35postgres |
36postgres | CREATE ROLE
37postgres |
38postgres |
39postgres | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/00-initial-data.sql
40postgres | CREATE EXTENSION
41postgres | CREATE TABLE
42postgres |
43postgres |
44postgres | LOG: received fast shutdown request
45postgres | LOG: aborting any active transactions
46postgres | waiting for server to shut down....LOG: autovacuum launcher shutting down
47postgres | LOG: shutting down
48postgres | LOG: database system is shut down
49postgres | done
50postgres | server stopped
51postgres |
52postgres | PostgreSQL init process complete; ready for start up.
53postgres |
54postgres | LOG: database system was shut down at 2017-03-22 21:36:16 UTC
55postgres | LOG: MultiXact member wraparound protections are now enabled
56postgres | LOG: database system is ready to accept connections
57postgres | LOG: autovacuum launcher started
58
59docker exec -it $(my postgres container id) sh
60
61#su - postgres
62
63#psql
64
65# d => No relations found.