I need to create extensions for a Postgres instance running inside of Docker - specifically postgis. I have followed other SO posts, including this one, to no avail.
Here's what I have so far...
Dockerfile
FROM postgres
COPY ext-script.sql /docker-entrypoint-initdb.d
ext-script.sql
create extension pgcrypto;
create extension postgis;
Docker run command
docker run -d -p 5432:54323 -e POSTGRES_PASSWORD=somepassword -e POSTGRES_USER=someuser -v postgres-data:/var/lib/postgresql/data --name dbcontainer dbimage
logs
docker logs dbcontainer
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/ext-script.sql
CREATE EXTENSION
2020-02-20 22:18:01.090 UTC [60] ERROR: could not open extension control file "/usr/share/postgresql/12/extension/postgis.control": No such file or directory
2020-02-20 22:18:01.090 UTC [60] STATEMENT: create extension postgis;
psql:/docker-entrypoint-initdb.d/ext-script.sql:2: ERROR: could not open extension control file "/usr/share/postgresql/12/extension/postgis.control": No such file or directory
What am I missing?
UPDATE
I ended up using the postgis dockerhub image.
Everything is easy when you know how :)
# Dockerfile
FROM postgis/postgis
COPY data.sql /docker-entrypoint-initdb.d