Cannot create POSTGIS extension in postgres in my docker image

Viewed 1500

While I'm typing

CREATE EXTENSION postgis;

or

CREATE EXTENSION IF NOT EXISTS postgis;

I'm getting an error saying:

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

Who can help?

1 Answers

You're probably using the Alpine version, meaning PostGIS can't be added that way.

See https://github.com/docker-library/docs/tree/master/postgres#additional-extensions

When using the Alpine variants, any postgres extension not listed in postgres-contrib will need to be compiled in your own image

Rather use an image that has PostGIS baked into it, e.g. postgis/postgis

or

Create your own Alpine based dockerfile that mimics the example they provide:
https://github.com/postgis/docker-postgis/blob/master/12-3.0/alpine/Dockerfile

Related