-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
85 lines (60 loc) · 3.34 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
-----------------------------------------------------------------------------
Dockerfiles for Fedora PostgreSQL Spin, with PGDG RPM packages
Devrim Gündüz <[email protected]>
Parts of this document is taken from:
https://docs.docker.com/engine/examples/postgresql_service/
-----------------------------------------------------------------------------
Contents:
---------
1) Introduction
2) Building an image from the Dockerfile
3) Running the PostgreSQL server container
4) Connecting to the PostgreSQL server container
5) Further information resource
1) Introduction
-----------------------------------------------------------------------------
This document exists to explain the layout of the Docker images for
PostgreSQL, based on PGDG RPMs, and the document the procedures.
PostgreSQL YUM Repository Project provides Dockerfiles for the latest
Fedora and CentOS distributions. More may/will come later.
2) Building an image from the Dockerfile
-----------------------------------------------------------------------------
After downloading the suitable Dockerfile (and renaming it to
"Dockerfile", run this command to build an image from the Dockerfile:
docker build -t pgdg_postgresql .
3) Running the PostgreSQL server container
-----------------------------------------------------------------------------
After creating the image, run this image in the background:
docker run -d -P --name pg_yum_test pgdg_postgresql
You can run the image in foreground by running this command:
docker run --rm -P --name pg_yum_test pgdg_postgresql
4) Connecting to the PostgreSQL server container
-----------------------------------------------------------------------------
There are two ways to connect to the PostgreSQL server container:
a) Using container linking
Containers can be linked to another container’s ports directly using
-link remote_name:local_alias in the client’s docker run. This will set
a number of environment variables that can then be used to connect:
$ docker run --rm -t -i --link pg_yum_test:pg pgdg_postgresql bash
$ psql -h $PG_PORT_5432_TCP_ADDR -p $PG_PORT_5432_TCP_PORT -d docker -U docker --password
b) Connecting from your host system
Assuming you have the postgresql96/postgresql10 packages installed, you
can use the host-mapped port to test as well. You need to use docker ps
to find out what local host port the container is mapped to first. See
the PORTS section in the output. An example is:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fe9158def36b eg_postgresql "/usr/pgsql-13/bin/p" About a minute ago Up About a minute 0.0.0.0:32773->5432/tcp pg_yum_test
In this example, 32773 is the port for the PostgreSQL instance. Now,
connect to the instance by:
psql -h localhost -p 32773 -d docker -U docker --password
Please note that you may change "localhost" to the host address on some
platforms.
If everything goes normal, you should see the psql prompt.
5) Further information resource
-----------------------------------------------------------------------------
You can get more information at https://www.pgdocker.org and
https://yum.postgresql.org
Please help make this images better -- let us know if you find
problems, or better ways of doing things. You can reach us by e-mail at