Giter VIP home page Giter VIP logo

docker-postgis's Introduction

postgis/postgis

Build Status Join the chat at https://gitter.im/postgis/docker-postgis

The postgis/postgis image provides tags for running Postgres with PostGIS extensions installed. This image is based on the official postgres image and provides debian and alpine variants for PostGIS 3.4.x, which is compatible with PostgreSQL versions 12, 13, 14, 15, and 16. Additionally, an image version is provided which is built from the latest two versions of Postgres (15, 16) with versions of PostGIS and its dependencies built from their respective master branches.

This image ensures that the default database created by the parent postgres image will have the following extensions installed:

installed extensions initialized
postgis yes
postgis_topology yes
postgis_tiger_geocoder yes
postgis_raster
postgis_sfcgal
address_standardizer
address_standardizer_data_us

Unless -e POSTGRES_DB is passed to the container at startup time, this database will be named after the admin user (either postgres or the user specified with -e POSTGRES_USER). If you would prefer to use the older template database mechanism for enabling PostGIS, the image also provides a PostGIS-enabled template database called template_postgis.

Versions (2024-02-17)

Supported architecture: amd64 (also known as X86-64)"

Recommended version for new users: postgis/postgis:16-3.4

Debian based (recommended)

  • This Docker-PostGIS version has a cautious release cycle to guarantee high stability.
    • By "cautious", we mean it does not always have the latest versions of geos, proj, gdal, and sfcgal packages.
  • We use PostGIS, geos, proj, gdal, and sfcgal packages from the Debian repository.
    • In the Debian Bullseye repository, the versions are: geos=3.9, gdal=3.2, proj=7.2, and sfcgal=1.3.9.
  • This version is easy to extend and has matured over time.
DockerHub image Dockerfile OS Postgres PostGIS
postgis/postgis:12-3.4 Dockerfile debian:bullseye 12 3.4.2
postgis/postgis:13-3.4 Dockerfile debian:bullseye 13 3.4.2
postgis/postgis:14-3.4 Dockerfile debian:bullseye 14 3.4.2
postgis/postgis:15-3.4 Dockerfile debian:bullseye 15 3.4.2
postgis/postgis:16-3.4 Dockerfile debian:bullseye 16 3.4.2

Alpine based

  • The base operating system is Alpine Linux. It is designed to be small, simple, and secure, and it's based on musl libc.
  • In the Alpine 3.18 version, the package versions are: geos=3.11, gdal=3.6, proj=9.2, and sfcgal=1.4.
  • PostGIS is compiled from source, making it a bit more challenging to extend.
DockerHub image Dockerfile OS Postgres PostGIS
postgis/postgis:12-3.4-alpine Dockerfile alpine:3.18 12 3.4.2
postgis/postgis:13-3.4-alpine Dockerfile alpine:3.18 13 3.4.2
postgis/postgis:14-3.4-alpine Dockerfile alpine:3.18 14 3.4.2
postgis/postgis:15-3.4-alpine Dockerfile alpine:3.18 15 3.4.2
postgis/postgis:16-3.4-alpine Dockerfile alpine:3.18 16 3.4.2

Test images

  • We provide alpha, beta, release candidate (rc), and development (identified as ~master) versions.
  • The template for the *-master images is updated manually, which might lead to a delay of a few weeks sometimes.
  • The ~master SFCGAL version is 1.5 or higher. The cgal version is locked on the 5.6.x-branch.
DockerHub image Dockerfile OS Postgres PostGIS
postgis/postgis:15-master Dockerfile debian:bullseye 15 development: postgis, geos, proj, gdal
postgis/postgis:16-master Dockerfile debian:bullseye 16 development: postgis, geos, proj, gdal

Usage

In order to run a basic container capable of serving a PostGIS-enabled database, start a container as follows:

docker run --name some-postgis -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis

For more detailed instructions about how to start and control your Postgres container, see the documentation for the postgres image here.

Once you have started a database container, you can then connect to the database either directly on the running container:

docker exec -ti some-postgis psql -U postgres

... or starting a new container to run as a client. In this case you can use a user-defined network to link both containers:

docker network create some-network

# Server container
docker run --name some-postgis --network some-network -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis

# Client container
docker run -it --rm --network some-network postgis/postgis psql -h some-postgis -U postgres

Check the documentation on the postgres image and Docker networking for more details and alternatives on connecting different containers.

See the PostGIS documentation for more details on your options for creating and using a spatially-enabled database.

Supported Environment Variables:

Since the docker-postgis repository is an extension of the official Docker PostgreSQL repository, all environment variables supported there are also supported here:

  • POSTGRES_PASSWORD
  • POSTGRES_USER
  • POSTGRES_DB
  • POSTGRES_INITDB_ARGS
  • POSTGRES_INITDB_WALDIR
  • POSTGRES_HOST_AUTH_METHOD
  • PGDATA

Read more: https://github.com/docker-library/docs/blob/master/postgres/README.md

Warning: the Docker specific variables will only have an effect if you start the container with a data directory that is empty; any pre-existing database will be left untouched on container startup.

It's important to note that the environment variables for the Docker image are different from those of the libpq โ€” C Library (PGDATABASE,PGUSER,PGPASSWORD )

Troubleshooting tips:

Troubleshooting can often be challenging. It's important to know that the docker-postgis repository is an extension of the official Docker PostgreSQL repository. Therefore, if you encounter any issues, it's worth testing whether the problem can be reproduced with the official PostgreSQL Docker images. If so, it's recommended to search for solutions based on this. The following websites are suggested:

If your problem is Postgis related:

And if you don't have a postgres docker experience - read this blog post:

Security

It's crucial to be aware that in a cloud environment, with default settings, these images are vulnerable, and there's a high risk of cryptominer infection if the ports are left open. ( Read More )

  • Note that ports which are not bound to the host (i.e., -p 5432:5432 instead of -p 127.0.0.1:5432:5432) will be accessible from the outside. This also applies if you configured UFW to block this specific port, as Docker manages its own iptables rules. ( Read More )

Recomendations:

  • You can add options for using SSL ( see postgres example )
    • -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key
  • Or you can use SSH Tunnels with -p 127.0.0.1:5432:5432

Security scanner information:

Limitations on Updates:

Unfortunately, we don't have control over updates to Debian and Alpine distributions or the upstream postgres image. Because of this, there might be some issues that we cannot fix right away. On the positive side, the postgis/postgis images are regenerated every Monday. This process is to ensure they include the latest changes and improvements. As a result, these images are consistently kept up-to-date.

Suggestions Welcome:

We are always open to suggestions to enhance security. If you have any ideas, please let us know.

Known Issues / Errors

When You encouter errors due to PostGIS update OperationalError: could not access file "$libdir/postgis-X.X, run:

docker exec some-postgis update-postgis.sh

It will update to Your newest PostGIS. Update is idempotent, so it won't hurt when You run it more than once, You will get notification like:

Updating PostGIS extensions template_postgis to X.X.X
NOTICE:  version "X.X.X" of extension "postgis" is already installed
NOTICE:  version "X.X.X" of extension "postgis_topology" is already installed
NOTICE:  version "X.X.X" of extension "postgis_tiger_geocoder" is already installed
ALTER EXTENSION
Updating PostGIS extensions docker to X.X.X
NOTICE:  version "X.X.X" of extension "postgis" is already installed
NOTICE:  version "X.X.X" of extension "postgis_topology" is already installed
NOTICE:  version "X.X.X" of extension "postgis_tiger_geocoder" is already installed
ALTER EXTENSION

Contributor guideline

This Docker-PostGIS project is part of the PostGIS group and follows more flexible contributor rules.

  • Please take a moment to review the current issues, discussions, and pull requests before you start.
  • If you have a major change in mind, we kindly ask you to start a discussion about it first.
  • After making changes to the templates, please run the ./update.sh script.

Code of Conduct

see: https://postgis.net/community/conduct/

docker-postgis's People

Contributors

amercader avatar bryanquigley avatar gitter-badger avatar imomaliev avatar imresamu avatar iqqmut avatar jacobhayes avatar jjmata avatar lbartoletti avatar lechup avatar luckyguido avatar md5 avatar nertzy avatar nyurik avatar phillipross avatar rahul-ve avatar rick avatar robe2 avatar smellman avatar stepankuzmin avatar strk avatar ubergesundheit avatar zachsa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-postgis's Issues

How to update underlying postgres

Probably the wrong place to ask this - not sure where is the right place.

I'm using this image as part of a docker-compose setup. Last week Postgres released a security update that I'd like to apply.

How do I do this? I noticed that the underlying postgres image was updated last week, but have rebuilt my setup after a docker purge / complete reset via docker for mac. But the image isn't the latest one from last week.

am I doing anything wrong? is there a way to apply the upgrade directly to my container so that it works until the patch is applied?

Improvements on $libdir/postgis-2.2

I started getting could not access file "$libdir/postgis-2.2": No such file or directory a couple of days ago on my mdillon/postgis:9.5-alpine image and even after i ran docker exec some-postgis update-postgis.sh it did not work for me because it was complaining about ERROR: extension "postgis_tiger_geocoder" does not exist.

Digging a bit further i found that the current update-postgis.sh ( 25373b2#diff-be90b6e0b4f64886cc3f7c44e5670e07 ) does not take into account a "fresh database" created by the final user without postgis_tiger_geocoder which was my case.

So to fix it i just entered my database and manually ran the commands (without caring about postgis_tiger_geocoder):

postgres=# SELECT PostGIS_full_version();
ERROR:  could not access file "$libdir/postgis-2.2": No such file or directory
CONTEXT:  SQL statement "SELECT postgis_lib_version()"
PL/pgSQL function postgis_full_version() line 22 at SQL statement
postgres=# ALTER EXTENSION postgis  UPDATE TO '2.3.2';
ALTER EXTENSION
postgres=# ALTER EXTENSION postgis_topology UPDATE TO '2.3.2';
ALTER EXTENSION
postgres=# SELECT PostGIS_full_version(); 

This fixed it for me, but as an improvement maybe we could make the update-postgis.sh ensure the extensions are already created before trying to Alter them and failing in doing so.

UPDATE:

This happened to me again and to fix it i:

ALTER EXTENSION postgis UPDATE;
ALTER EXTENSION postgis_topology UPDATE;

Package Issues

Hello,

I had no problems installing via the automated build, but if I download the docker file and corresponding script and try to manually build the file the installation halts at step 5 with the following error message:

E: Version '2.3.0+dfsg-2~132.gitddacceb.pgdg80+6' for 'postgresql-9.6-postgis-2.3' was not found
E: Version '2.3.0+dfsg-2~132.gitddacceb.pgdg80+6' for 'postgis' was not found
The command '/bin/sh -c apt-get update       && apt-get install -y --no-install-recommends            postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION            postgis=$POSTGIS_VERSION       && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100

I am using docker version 1.9.1 on a opensuse machine. This happened both with the version for pg 9.5 and 9.6

Thanks

Postgres 10 releae?

Hi,

I'm wondering if you are planning to release a version of this image based on the newly released PostgreSQL 10.

Thanks!

Consider providing tags for PostGIS version

There are tags for the Postgres version, but it'd be nice to have them for the PostGIS version too. We've had issues when trying to upgrade our databases even with just minor PostGIS releases.

docker-entrypoint-initdb.d after CREATE EXTENSIONs

Guys, I need some help. I'm using docker-compose.
How do I run the docker-entrypoint-initdb.d script after Postgis EXTENSIONs are created?
Or maybe there is a different way of locating and naming my init script?

docker-compose.yml:

services:
  postgis:
    image: mdillon/postgis:latest
    volumes:
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    container_name: postgis
    ports:
      - "5432:5432"
    env_file:
      - .env

init.sql is a SQL file I have in the root of the project, with a table creation, using a GEOGRAPHY column.

CREATE TABLE public."addresses"(
    "address_id" INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    "coordinates" GEOGRAPHY(POINT) NULL
);

init.sql currently fails, because EXTENSIONs are created after the script is run.

ERROR:

psql:/docker-entrypoint-initdb.d/init.sql:4: ERROR:  type "geography" does not exist
postgis | LINE 3:     "coordinates" GEOGRAPHY(POINT) NULL,

Thanks!

Issue with postgis package on 9.4 & 9.5

I keep having issues when running the dockerFile here

https://github.com/appropriate/docker-postgis/blob/master/9.4-2.2/Dockerfile

It wasn't giving me issues earlier in the week, but I recently destroyed my images and tried to create a new one with the same dockerfile and keep getting the same errors. Tried doing it on multiple containers, including using postgres:9.5, is this a debian apt-get issue? I'm not sure.

Also have tried on multiple computers. same result, windows or mac.

E: Version '2.2.1+dfsg-2.pgdg80+1' for 'postgresql-9.4-postgis-2.2' was not found E: Version '2.2.1+dfsg-2.pgdg80+1' for 'postgis' was not found The command '/bin/sh -c apt-get update && apt-get install -y --no-install-recommends postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION postgis=$POSTGIS_VERSION && rm -rf /var/lib/apt/lists/* && apt-get -y autoclean' returned a non-zero code: 100

Rebuild images on the docker hub

I thought the postgis images were rebuilt automatically when official postgres images are pushed but it seems like they're not. This PR was merged, new postgres images were pushed to the hub and it didn't trigger any build.
Would you mind triggering a build manually ? Thanks ๐Ÿ™‚

password authentication failed

Using the default image, starting from the last couple of days, the docker image seems not to be correctly initialized.
The error in the console is the following:

postgres_1    | FATAL:  password authentication failed for user "postgres"
postgres_1    | DETAIL:  Password does not match for user "postgres".
postgres_1    | 	Connection matched pg_hba.conf line 95: "host all all all md5"

I think that this issue can be related to an issue of the original postgres image: docker-library/postgres#308

Unfortunately, I have this issue in my production environment, and I am quite scary to force use a particular version of postgres.

february 8th Postgresql update

Could you please update docker to last postgresql versions ?
I tested and got an error for 9.5-2.4 but 10.2 works well.

10.2, 9.6.7, 9.5.11, 9.4.16, and 9.3.21.

E: Version '2.3.2+dfsg-1~exp2.pgdg80+1' for 'postgresql-9.6-postgis-2.3' was not found

Hey. When I try to use it with Django, I get such a mistake.

Previously, everything worked, but now this error:

E: Version '2.3.2+dfsg-1~exp2.pgdg80+1' for 'postgresql-9.6-postgis-2.3' was not found
E: Version '2.3.2+dfsg-1~exp2.pgdg80+1' for 'postgresql-9.6-postgis-2.3-scripts' was not found
E: Version '2.3.2+dfsg-1~exp2.pgdg80+1' for 'postgis' was not found

Docker Build Failure

Hey, I'm trying to build this docker image on an Ubuntu 15.10 machine. When I run the command "sudo docker build -t postgres_image .", I get the build version errors found bolded below. Can anyone help with this?

Sending build context to Docker daemon 17.41 kB
Step 1 : FROM postgres:9.6
---> d12be754b938
Step 2 : MAINTAINER Mike Dillon [email protected]
---> Using cache
---> c36894d74f99
Step 3 : ENV POSTGIS_MAJOR 2.3
---> Using cache
---> fe4d2edd379a
Step 4 : ENV POSTGIS_VERSION 2.3.0+dfsg-2.pgdg80+1
---> Using cache
---> 3dd26124953f
Step 5 : RUN apt-get update && apt-get install -y --no-install-recommends postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION postgis=$POSTGIS_VERSION && rm -rf /var/lib/apt/lists/*
---> Running in 8e07192ff31d
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Get:2 http://apt.postgresql.org jessie-pgdg InRelease [46.5 kB]
Get:3 http://apt.postgresql.org jessie-pgdg/main amd64 Packages [107 kB]
Ign http://deb.debian.org jessie InRelease
Get:4 http://security.debian.org jessie/updates/main amd64 Packages [421 kB]
Get:5 http://apt.postgresql.org jessie-pgdg/9.6 amd64 Packages [20 B]
Get:6 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:7 http://deb.debian.org jessie Release.gpg [2,373 B]
Get:8 http://deb.debian.org jessie-updates/main amd64 Packages [17.6 kB]
Get:9 http://deb.debian.org jessie Release [148 kB]
Get:10 http://deb.debian.org jessie/main amd64 Packages [9,064 kB]
Fetched 10.0 MB in 3s (2,929 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
E: Version '2.3.0+dfsg-2.pgdg80+1' for 'postgresql-9.6-postgis-2.3' was not found
E: Version '2.3.0+dfsg-2.pgdg80+1' for 'postgresql-9.6-postgis-2.3-scripts' was not found
E: Version '2.3.0+dfsg-2.pgdg80+1' for 'postgis' was not found

The command '/bin/sh -c apt-get update && apt-get install -y --no-install-recommends postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION postgis=$POSTGIS_VERSION && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100

ERROR: required extension "postgis" is not installed

Host OS: Ubuntu 14.04
Docker version: 1.3.3

Dockerfile:

FROM mdillon/postgis:9.3

# Add init script
ADD initdb-foo.sh /docker-entrypoint-initdb.d/foo.sh

# Add locale
RUN echo "nb_NO.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen

initdb-foo.sh:

#!/bin/sh
POSTGRES="gosu postgres postgres"

$POSTGRES --single -E <<EOSQL
CREATE DATABASE foo template template0 lc_collate 'nb_NO.UTF-8' lc_ctype 'nb_NO.UTF-8';
EOSQL

$POSTGRES --single foo -E <<EOSQL
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
EOSQL

I get the following output when I run my Dockerfile:

PostgreSQL stand-alone backend 9.3.5
backend> statement: CREATE DATABASE foo template template0 lc_collate 'nb_NO.UTF-8' lc_ctype 'nb_NO.UTF-8';

backend> 
PostgreSQL stand-alone backend 9.3.5
backend> statement: CREATE EXTENSION postgis;

ERROR:  type addbandarg[] does not exist
STATEMENT:  CREATE EXTENSION postgis;

backend> statement: CREATE EXTENSION postgis_topology;

ERROR:  required extension "postgis" is not installed
STATEMENT:  CREATE EXTENSION postgis_topology;

backend> LOG:  database system was shut down at 2015-01-16 14:10:49 UTC

docker-compose ?

Hi,

I am very new to docker, and I did this docker-compose.yml file to make it easy to start the container:

postgis:
    image: mdillon/postgis
    volumes:
        - C:\Users\Sabri\Documents\postgis-data-folder:/var/lib/postgresql/data

    env_file: .postgis_env

    ports:
        - "9090:9000"
        - "54320:5432"
    links:
      - database
    container_name: postgis

database:
  image: postgres:9.4.4
  env_file: .env
  environment:
    LC_ALL: C.UTF-8
  container_name: postgres_database

it worked fine, and I could connect to db using 192.168.99.100:54320
however, do I need to link to image postgres:9.4.4 ?
I've noticed that I have stopped the postgres_database container, and my app worked normally, please advice!

Also, how would I check the database file? for ex: size ? where is it stored?

Thank you

Enabling hstore extension for postgis db

I was trying to use osm2pgsql command to import data to a db. However got the error:

type "hstore" does not exist

Error was fixed by enabling hstore extension for the db. Do you think it might be handy to enable it by default during db creation phase?

I could prepare PR if the answer will be "yes".

postgis updated to 2.4.3

The package postgis was updated on apt.postgresql.org:

New version 2.4.3+dfsg-2.pgdg+1:

postgis                             |  2.4.3+dfsg-2.pgdg+1                          |  sid-pgdg      |  amd64,  i386,    ppc64el,  source
postgis                             |  2.4.3+dfsg-2.pgdg100+1                       |  buster-pgdg   |  amd64,  i386,    ppc64el,  source
postgis                             |  2.4.3+dfsg-2.pgdg90+1                        |  stretch-pgdg  |  amd64,  i386,    ppc64el,  source
postgis                             |  2.4.3+dfsg-2.pgdg80+1                        |  jessie-pgdg   |  amd64,  i386,    ppc64el,  source
postgis                             |  2.3.3+dfsg-1.pgdg70+2                        |  wheezy-pgdg   |  amd64,  i386,    source
postgis                             |  2.4.3+dfsg-2.pgdg18.04+1                     |  bionic-pgdg   |  amd64,  i386,    ppc64el,  source
postgis                             |  2.4.2+dfsg-1.pgdg17.04+1                     |  zesty-pgdg    |  amd64,  i386,    ppc64el,  source
postgis                             |  2.4.3+dfsg-2.pgdg16.04+1                     |  xenial-pgdg   |  amd64,  i386,    ppc64el,  source
postgis                             |  2.2.2+dfsg-4.pgdg15.10+1                     |  wily-pgdg     |  amd64,  i386,    source
postgis                             |  2.1.8+dfsg-5~97.git43a09cc.pgdg14.10+1       |  utopic-pgdg   |  amd64,  i386,    source
postgis                             |  2.4.3+dfsg-2.pgdg14.04+1                     |  trusty-pgdg   |  amd64,  i386,    ppc64el,  source
postgis                             |  2.1.3+dfsg-3.pgdg13.10+2                     |  saucy-pgdg    |  amd64,  i386,    source
postgis                             |  2.3.2+dfsg-1~exp2.pgdg12.4+1                 |  precise-pgdg  |  amd64,  i386,    source

source : https://www.postgresql.org/message-id/E1ebrVj-00010r-L2%40atalia.postgresql.org

alpine variants

The official postgres repository offers alpine variants, it would be really nice if you could provide alpine variants as well :)

Unable to access function PostGIS_Lib_Version

Hello,

I'm trying to implement PostGIS in my project, using your image mdillon/postgis:10-alpine and jsor/doctrine-postgis PHP library. It tries to use PostGIS_Lib_Version() function, but I have the following error:

capture d ecran 2017-12-27 a 14 57 03

Here is a part of my docker configuration:

version: '3'

services:
  # ...
  db:
    image: mdillon/postgis:10-alpine
    healthcheck:
      test: chmod +x /usr/local/bin/healthcheck && /usr/local/bin/healthcheck
    environment:
      - POSTGRES_DB=api_platform
      - POSTGRES_PASSWORD=api_platform
    volumes:
      - ./docker/postgres/healthcheck.sh:/usr/local/bin/healthcheck:rw

I also tried to execute update-postgis.sh script, but everything seems ok:

docker exec -e POSTGRES_USER=postgres db update-postgis.sh

capture d ecran 2017-12-27 a 15 08 29

Is there anything I missed?

Having issue when putting in env vars

Hi,

I already installed postgis without problem on another dokku machine. But since I upgraded on another machine I've somme issue to install the postgis.

I've done the instructions, and when I try to use the images for postgres plugins he says :
docker: Error parsing reference: "mdillon/postgis" latest" is not a valid repository/tag.

here are my env

export POSTGRES_IMAGE="mdillon/postgis"
export POSTGRES_IMAGE_VERSION="latest"

thanks in advance

Should we use `CREATE EXTENSION ... CASCADE`?

Maybe I'm doing something wrong, but I'm trying to use the instructions at the bottom of this to get arround the following error:

ERROR:  could not stat file "/usr/local/share/postgresql/extension/postgis--2.4.2.sql": No such file or directory

So here is what I am doing:

docker exec -e POSTGRES_USER=brian -e POSTGRES_DB=foo pg_c update-postgis.sh

Which gives me:

NOTICE:  extension "postgis" already exists, skipping
NOTICE:  version "2.4.0" of extension "postgis" is already installed
NOTICE:  extension "postgis_topology" already exists, skipping
NOTICE:  version "2.4.0" of extension "postgis_topology" is already installed
NOTICE:  extension "postgis_tiger_geocoder" already exists, skipping
NOTICE:  version "2.4.0" of extension "postgis_tiger_geocoder" is already installed
Updating PostGIS extensions 'template_postgis' to 2.4.0
ALTER EXTENSION
Updating PostGIS extensions 'foo' to 2.4.0
NOTICE:  version "2.4.0" of extension "postgis" is already installed
NOTICE:  version "2.4.0" of extension "postgis_topology" is already installed
ERROR:  required extension "fuzzystrmatch" is not installed
HINT:  Use CREATE EXTENSION ... CASCADE to install required extensions too.

Specific tags for each Postgis version

I think it is better to have specific tags for each Postgis version, like:

  • 9.1-2.1
  • 9.2-2.1
  • 9.3-2.1
  • 9.4-2.1
  • 9.5-2.1
  • 9.4-2.2
  • 9.5-2.2
  • 9.4 --> using PostgreSQL 9.4 and latest Postgis version
  • 9.5 --> using PostgreSQL 9.5 and latest Postgis version
  • ...

This to make sure the other images those depend on this will not broken.

Enable PostGIS extensions on default database

The postgres container implicitly creates a database for the postgres user (or the user specified at container creation by setting $POSTGRES_USER to something other than postgres). It might be nice if that database had the PostGIS extension installed automatically so that this image could work out of the box.

Specify postgis versions in docker tags

We have deployed databases that are on 9.3/2.1 (in process of migrating to 9.5/2.2) and don't want to upgrade developer databases until we have a clear migration path for deployed environments. Since these images aren't tagged with the postgis version we can't stay on 2.1 without vendoring the old dockerfile (which we'd rather not do).

9.x/2.1 combinations wouldn't necessarily need to be maintained, like 9.0 is now - tagged, but not updated.

Error on pre-existing databases with new images if it was initialized with PostGIS 2.1

When updating/rebuilding images with the latest versions (which has PostGIS 2.2 instead), queries fail with "OperationalError: could not access file "$libdir/postgis-2.1": No such file or directory" on pre-existing databases created before #8 was in place.

Per upgrading information from http://postgis.net/install/, you need to execute more commands for each database so you can complete the upgrade to 2.2:

-- Upgrade PostGIS (includes raster)
ALTER EXTENSION postgis 
 UPDATE TO "2.2.1";
-- Upgrade Topology
ALTER EXTENSION postgis_topology 
 UPDATE TO "2.2.1";

-- Upgrade US Tiger Geocoder
ALTER EXTENSION postgis_tiger_geocoder 
 UPDATE TO "2.2.1";

While this can be done manually by admins, wouldn't it perhaps be better if this was included in the startup if it detects the default database is not yet upgraded from 2.1 to 2.2?

If not, it would really be better to have a version pin for 2.1. Looking at #8 where 2.2 was introduced, this may seem hard, but since that issue is closed, I've made this new one so this can be tracked separately.

Possible to link against GEOS 3.5.0+?

Hey there,

I have a query that uses ST_ClipByRect, which requires postgis 2.2 and GEOS 3.5+. Any idea how I can produce such an image?

Thanks,
Evan

P.S. Current pg95 image is producing this error for my query: InternalError("The GEOS version this PostGIS binary was compiled against (34) doesn't support 'GEOSClipByRect' function (3.5.0+ required)\n",)

pg_dump missing table data after starting the container

We've been trying to backup a populated postgis database using pg_dump and haven't had much success.

So we went back to the simplest Dockerfile

FROM mdillon/postgis

After starting the container, we immediately bash'd in and ran pg_dump:

pg_dump -Upostgres -c postgres > dump

The dump file doesn't contain most of the useful seed tables, like state_lookup

We've tried many variations using pg_dumpall, specifying the schema using -n tiger, trying to grab specific tables, none have been successful.

Obviously this isn't a huge issue until we use the loader_generate scripts to pull in several download hours worth of data. How do we back up the database inside this container?

No postgis enabled?

So I started the container:
docker run -d -it --name postgis -p 5432:5432 mdillon/postgis:9.6

Created a DB and tried to create a table:

CREATE TABLE mytable (
id SERIAL PRIMARY KEY,
geom GEOMETRY(Point, 26910),
name VARCHAR(128)
);

And got:

ERROR: type "geometry" does not exist
LINE 3: geom GEOMETRY(Point, 26910),
^

********** Error **********

ERROR: type "geometry" does not exist
SQL state: 42704
Character: 57

'/docker-entrypoint.sh' not found

After update to go 1.7 I have this error
docker: Error response from daemon: Container command '/docker-entrypoint.sh' not found or does not exist.
I can`t even start container to see if this file exists

9.5-2.2 build error

With specifying POSTGIS_VERSION 2.2.2+dfsg-1.pgdg80+1 docker not build:

E: Version '2.2.2+dfsg-1.pgdg80+1' for 'postgresql-9.5-postgis-2.2' was not found
E: Version '2.2.2+dfsg-1.pgdg80+1' for 'postgis' was not found

Need change POSTGIS_VERISON to 2.2.2+dfsg-1.pgdg80+4

May be there is no need to specifying POSTGIS_VERSION ?

ERROR: could not open extension control file "/usr/share/postgresql/9.4/extension/postgis.control": No such file or directory

Hi,

I tried to run CREATE EXTENSION postgis; on the image mdillon/postgis:9.4 from the docker hub. It complained that it couldn't find the file /usr/share/postgresql/9.4/extension/postgis.control

running bash inside the container reveals that in fact this file exists!

I already tried the following things:

  • building from this repository
  • changing ownership of /usr/share/postgresql/9.4/extension/ to the postgres user (RUN chown -R postgres:postgres /usr/share/postgresql/9.4/extension/)

Could you please look into this?

Cheers

POSTGIS_VERSION upgrade

I found the POSTGIS_VERSION is not longer available for building docker template.
It appears to be upgrading from
ENV POSTGIS_VERSION 2.3.2+dfsg-1exp1.pgdg80+1 to ENV POSTGIS_VERSION 2.3.2+dfsg-1exp2.pgdg80+1

Viewing in QGIS?

How would I go about viewing my PostGIS data in QGIS? Since the container does not expose any ports I'm not sure how I'm supposed to go about doing it.

Creating tags for minor version of Postgres

Hi,

I see you are creating your images from postgres:9.5 for example.

The issue with that is you will get the 9.5 version at the image build time (could be 9.5.2 or whatever).
As a result you will not getting the latest 9.5 when pulling your image. Which is a bit misleading.

So, to ensure the latest version part of your image, you would need to build

FROM postgres:9.5.10

and tag it appropriately mdillon/postgis:9.5.10

Which bring the question of the versioning of PostGIS in the tag too.

mdillon/postgis:9.5.10-2.4.3

What do you think?

Mounting volume on /docker-entrypoint.d prevents postgis initialization

I'm using docker-compose and I'd like to run some .sql files when the container starts up, but that conflicts with COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh in the Dockerfile.

  postgresql:
    image: mdillon/postgis:latest
    ports:
      - "5432:5432"
    volumes:
      - ./postgresql:/docker-entrypoint-initdb.d
    environment:
      - POSTGRES_USER=test
      - POSTGRES_PASSWORD=test
      - POSTGRES_DB=test

From what I've read, this is the expected behavior for docker volumes so I don't think this is a bug in your project, but I'm wondering if you're aware of a workaround.

Latest tag fails to start

It fails with

/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/postgis.sh
FATAL:  lock file "postmaster.pid" already exists
HINT:  Is another postmaster (PID 55) running in data directory "/var/lib/postgresql/data"?

Rolling it back to a tag 10 days ago (22ed955cce18) works

Startup time in Continuous Build scenarios

Hi,

I'm planning to swap over from the official postgres image to mdillon/postgis to start working with postgis features in a site I'm building. We use docker in circleci for continuous build and test, and then docker cloud for continuous deployment. This works well with postgres but not with postgis.

We have (in essence) three containers: web, test and db. Web has a link to db; test has a link to web.

The postgres docker container starts postgres almost immediately and is ready to receive connections. The postgis image takes a lot longer to ready the postgis extension and start accepting connections. This kind of problem is not uncommon in docker when services take some time to come online.

docker recently introduced HEALTHCHECK to allow a container to say when it was ready to receive requests, and to continue to provide a status once running. (https://docs.docker.com/engine/reference/builder/#/healthcheck)

It would be super helpful if mdillon/postgis implemented HEALTHCHECK.

Provide postgis_sfcgal extension

Hey Mike,

that's a great image of PostGIS - I was wondering if you could add PostGIS' postgis_sfcgal extension to your docker-postgis 9.6-2.3 image too? I'd provide you a pull request, ofc.

Kind regards,
Matthias R.

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.