I'm 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 running the image
backend> statement: CREATE EXTENSION postgis;
ERROR: type addbandarg[] does not exist STATEMENT: CREATE EXTENSION postgis;
backend> statement: CREATE EXTENSION postgis_topology;
backend> ERROR: required extension "postgis" is not installed
I'm doing something wrong obviously, but I don't know what. Why is postgis in not installed if I've installed postgis with apt-get.
PostGIS is an extension to PostgreSQL for storing and managing spatial information. To learn more about PostGIS, see PostGIS.net . Starting with version 10.5, PostgreSQL supports the libprotobuf 1.3. 0 library used by PostGIS for working with map box vector tile data.
Developers can perform Data Processing Operations using any Database Management System (DBMS) like PostgreSQL by pulling in their respective Docker Image files from the Docker Hub.
---DOCKERFILE
FROM postgres:12.4
RUN apt-get update \
&& apt-get install wget -y \
&& apt-get install postgresql-12-postgis-3 -y \
&& apt-get install postgis -y
COPY ./db.sql /docker-entrypoint-initdb.d/
--- db.sql (in this same folder)
CREATE EXTENSION postgis;
I am using CentOS rather than Debian but ran into the same problem. The solution basically came 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With