-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.docker
50 lines (41 loc) · 2.73 KB
/
install.docker
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
## -- Copyright Johann Höchtl 2016 https://github.com/the42/bevaddress-dataload
##
## This script installs PostgreSQL including POSTGIS support via Docker
# Documentation is available as
# - for PostgreSQL on Docker https://hub.docker.com/_/postgres/
# - for PostGIS on Docker https://hub.docker.com/r/mdillon/postgis/
# - for Docker data container compartmentalization https://docs.docker.com/engine/userguide/dockervolumes/#creating-and-mounting-a-data-volume-container
## This script assumes that Docker is installed, read more at
# https://docs.docker.com/engine/installation/ubuntulinux/
# AND not requiring root access as described
# https://docs.docker.com/engine/installation/ubuntulinux/#create-a-docker-group
## Pull bevaddress image
docker pull the42/bevdockerdb
# Create the POSTGIS data store volume and a volume to hold the backups for database migration
docker create -v /var/lib/postgresql/data --name bevdata the42/bevdockerdb echo "Postgresql BEVADDRESS data directory"
docker create -v /var/lib/postgresql/backup --name bevdatabackup the42/bevdockerdb echo "Postgresql BEVADDRESS backup directory"
# !!!! Create the POSTGIS instance. Replace <YOURPASSWORD> with the password to access the database
export POSTGRES_PASSWORD=<YOURPASSWORD>
# The following command creates the dockerized POSTGIS-Database.
# !!!! If your installation does not allow arbitrary port access,
# for example when you create the instance on a remote cloud host,
# restrict the allowed port mappings by commenting the following line,
# uncommenting the line following the next line, and setting the allowed port range
# of parameter -p 6001:5432
# cf. documentation https://docs.docker.com/engine/reference/run/#expose-incoming-ports
docker run --name bevaddress -e POSTGRES_USER=bevsu -e POSTGRES_DB=bevaddress -P -d --volumes-from bevdata --volumes-from bevdatabackup the42/bevdockerdb
# docker run --name bevaddress -p 6001:5432 -e POSTGRES_USER=bevsu -e POSTGRES_DB=bevaddress -P -d --volumes-from bevdata --volumes-from bevdatabackup the42/bevdockerdb
##
## Test connection, maintainance and updates
##
## get the docker port and note the mapping
# docker port bevaddress
## Connect to the server to test connection
# psql -U bevsu -h <IP-Address> -p 6001 -d bevaddress # where -p <port> is the port reported from the above command
# Later you likely want to create a less-privileged user with read-only access
# to the database to perform queries and the like.
# See http://www.dbrnd.com/2015/10/postgresql-script-to-create-a-read-only-database-user/
## Upgrade the Postgres/PostGIS database while retaining the data
## TODO
## For a general procedure how to load a database backup see
## https://myprivate42.wordpress.com/2016/04/01/restore-a-postgres-backup-into-a-docker-container/