Git Product home page Git Product logo

docker-postgis's Introduction

Postgresql 9.3 + PostGIS 2.1

This is a PostGIS image suitable for development databases. The real strength of this image is external volume support. If you don't need that (i.e. you're using boot2docker), you should use a simpler PostGIS image.

Features:

  • Lets you use an external volume for data and logs
  • en_US.UTF-8 locale
  • Includes postgresql-client packages so you can use this image to make utility containers

Compromises:

  • Weak security to make it easier to connect to
  • Simplified logging to make the logs easier to watch

Auth

Login with the username docker and no password.

Example PostGIS Lifecycle

Based of the names and examples established in the makefile and using postdoc on a Linux box.

Start a PostGIS server

docker run --detach --name postgis -v ~/volumes/postgis:/data -p 5432:5432 crccheck/postgis
export DATABASE_URL=postgis://[email protected]:5432/states

Creating a database, "states"

Locally:

# "states" and connection args were set above in DATABASE_URL
phd createdb

Using this image as a utility container:

docker run --rm --name postgis-debug --link postgis:postgis -i -t \
  crccheck/postgis \
  createdb -U docker -h postgis -p 5432 states

Connect to the database using psql

Locally:

# "states" and connection args were set above in DATABASE_URL
phd psql

Using this image as a utility container:

docker run --rm --name postgis-debug --link postgis:postgis -i -t \
  crccheck/postgis \
  psql -U docker -h postgis -p 5432

Viewing logs

There are two and a half ways to view logs:

  1. Tail the logfile locally using the external volume:

     $ tail -f ~/volumes/postgis/logs/postgresql.log
    
  2. Tail the logfile in a utility container using the volume:

     $ docker run --rm --name postgis-debug --volumes-from postgis -i -t \
       ubuntu tail -f /data/logs/postgresql.log
    
  3. Attach to the running container (I don't think this currently works):

     docker attach --sig-proxy=false postgis
    

Temporarily stopping the container

You may want to stop the image to free up resources:

docker stop postgis

Restarting

You can restart the container after you stopped it (or after a reboot):

docker start postgis

Dumping the data to your local filesystem

Using pg_dump locally:

phd pd_dump -Fc > states.dump

And using a helper container:

docker run --rm --name postgis-debug --link postgis:postgis -i -t \
  crccheck/postgis \
  pg_dump -U docker -h postgis -p 5432 -Fc states

Removing the container

docker rm postgis

Removing the image

docker rmi crccheck/postgis

References


See my master repo at https://github.com/crccheck/docker-pod for more information.

docker-postgis's People

Contributors

crccheck avatar

Stargazers

Andrew Magill avatar Dan Keemahill avatar

Watchers

 avatar James Cloos avatar  avatar

docker-postgis's Issues

Automatically enable postgis stuff in template1?

Thoughts:

  1. automatically enabling extensions would probably save most people time
  2. managed DBs like RDS enable extensions with an admin, not the command line, so it wouldn't be an anti-pattern
  3. most developers probably have their own way they like to do template1, and assuming developers want it some way may be counterproductive

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.