2014-05-04 19:14:46 +00:00
|
|
|
# docker-postgis
|
2014-05-04 18:52:28 +00:00
|
|
|
|
2014-05-04 19:14:46 +00:00
|
|
|
A simple docker container that runs PostGIS
|
|
|
|
|
2014-05-04 19:35:49 +00:00
|
|
|
**Note:** We recommend using ``apt-cacher-ng`` to speed up package fetching -
|
|
|
|
you should configure the host for it in the provided 71-apt-cacher-ng file.
|
2014-05-04 19:14:46 +00:00
|
|
|
|
|
|
|
## Build
|
|
|
|
|
2014-05-04 19:47:26 +00:00
|
|
|
To build the image without apt-cacher do:
|
2014-05-04 19:14:46 +00:00
|
|
|
|
|
|
|
```
|
2014-05-04 19:47:26 +00:00
|
|
|
docker build -t kartoza/postgis:2.2 git://github.com/timlinux/docker-postgis
|
|
|
|
```
|
|
|
|
|
|
|
|
To build with apt-cache do you need to clone this repo locally first and
|
|
|
|
modify the contents of 71-apt-cacher-ng to match your cacher host. Then
|
|
|
|
build using a local url instead of directly from github.
|
|
|
|
|
|
|
|
```
|
|
|
|
git clone git://github.com/timlinux/docker-postgis
|
|
|
|
```
|
|
|
|
|
|
|
|
Now edit ``71-apt-cacher-ng`` then do:
|
|
|
|
|
|
|
|
```
|
|
|
|
docker build -t kartoza/postgis:2.2 .
|
2014-05-04 19:14:46 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Run
|
|
|
|
---
|
|
|
|
|
|
|
|
To create a running container do:
|
|
|
|
|
|
|
|
```
|
|
|
|
sudo docker run --name "postgis" -p 2222:22 -p 25432:5432 -d -t kartoza/postgis:2.1
|
|
|
|
```
|
|
|
|
|
|
|
|
## Connect via psql
|
|
|
|
|
|
|
|
To log in to your container do:
|
|
|
|
|
|
|
|
Connect with psql (make sure you first install postgresql client tools on your
|
|
|
|
host / client):
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
psql -h localhost -U docker -p 25432 -l
|
|
|
|
```
|
|
|
|
|
|
|
|
You can then go on to use any normal postgresql commands against the container.
|
|
|
|
|
|
|
|
Under ubuntu 14.04 the postgresql client can be installed like this:
|
|
|
|
|
|
|
|
```
|
|
|
|
sudo apt-get install postgresql-client-9.3
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
# Storing data on the host rather than the container.
|
|
|
|
|
|
|
|
|
|
|
|
Docker volumes can be used to persist your data.
|
|
|
|
|
|
|
|
```
|
|
|
|
mkdir -p ~/postgres_data
|
|
|
|
docker run -d -v $HOME/postgres_data:/var/lib/postgresql kartoza/postgis`
|
|
|
|
```
|
|
|
|
|
|
|
|
You need to ensure the ``postgres_data`` directory has sufficinet permissions
|
|
|
|
for the docker process to read / write it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Connect via ssh
|
|
|
|
---------------
|
|
|
|
|
|
|
|
To log into your container do:
|
|
|
|
|
|
|
|
```
|
|
|
|
ssh root@localhost -p 2222
|
|
|
|
```
|
|
|
|
|
|
|
|
Default ssh password is 'postgis'
|
|
|
|
|
|
|
|
|
|
|
|
Credits
|
|
|
|
-------
|
|
|
|
Tim Sutton (tim@linfiniti.com)
|
|
|
|
May 2014
|