I'm trying to install postgis into a postgres container. Dockerfile:
FROM postgres:9.6.4-alpine
RUN apk update \
&& apk add -u postgresql-9.6-postgis-2.4 postgresql-9.6-postgis-2.4-scripts \
&& rm -rf /var/lib/apt/lists/*
COPY ./scripts/postgis.sh /docker-entrypoint-initdb.d/postgis.sh
postgis.sh:
#!/bin/sh
for DB in $(psql -t -c "SELECT datname from pg_database where datname = 'backend'"); do
echo "Loading PostGIS extensions into $DB"
"${psql[@]}" --dbname="$DB" <<-'EOSQL'
CREATE EXTENSION IF NOT EXISTS postgis;
EOSQL
done
I got this error:
ERROR: unsatisfiable constraints: postgresql-9.6-postgis-2.4 (missing): required by: world[postgresql-9.6-postgis-2.4] postgresql-9.6-postgis-2.4-scripts (missing): required by: world[postgresql-9.6-postgis-2.4-scripts] The command '/bin/sh -c apk update && apk add -u postgresql-9.6-postgis-2.4 postgresql-9.6-postgis-2.4-scripts && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 2
I found similar questions such as :
- ERROR: unsatisfiable constraints: while installing package in alpine
- ERROR: unsatisfiable constraints - on php:7-fpm-alpine
But it doesn't solve my problem.How can I add postgis extension to my postgres container with apk?
postgis (missing): ERROR: unsatisfiable constraints: required by: world[postgis]
. I used the following command:echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && apk update && apk add -u postgis && rm -rf /var/lib/apt/lists/*
– Pygmy