How to create postgis extension for postgresql in docker?

I am getting errors when trying to create postgis extensions.

Here is what my dockerfile looks like.

from postgres RUN apt-get update && apt-get install postgis -y ADD /create_postgis_extension.sh /docker-entrypoint-initdb.d/ 

create.bla-bla..sh

 #!/bin/sh POSTGRES="gosu postgres postgres" $POSTGRES --single -E <<EOSQL CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology; EOSQL 

And here is the error when starting the image

backend>: CREATE EXTENSION postgis;

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

backend>: CREATE EXTENSION postgis_topology;

backend> ERROR: required postgis extension not installed

I am doing something wrong, but I do not know what. Why postgis is not installed if I installed postgis with apt-get.

+6
source share
1 answer

I am using CentOS, not Debian, but have run into the same problem. The solution basically boiled down to using pg_ctl to start / stop postgres.

 sudo -u postgres pg_ctl start -w -D ${PGDATA} sudo -u postgres createdb postgis_template -E UTF8 sudo -u postgres psql -d postgis_template -c "create extension if not exists postgis;" sudo -u postgres pg_ctl stop -w 
+2
source

Source: https://habr.com/ru/post/979860/


All Articles