Docker Community Forums

Share and learn in the Docker community.

ERROR: unsatisfiable constraints using apk in dockerfile

docker

(Slimhs) #1

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

Is it possible to use apk to download the postgis extension or not?


(Slimhs) #2

I fix this problem by:

FROM postgres:9.6.4-alpine

RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories

RUN apk update \
    && apk add -u postgis \
    && rm -rf /var/lib/apt/lists/*

COPY ./scripts/postgis.sh  /docker-entrypoint-initdb.d/postgis.sh