错误:在dockerfile中使用apk无法满足的约束 [英] ERROR: unsatisfiable constraints using apk in dockerfile

查看:358
本文介绍了错误:在dockerfile中使用apk无法满足的约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将postgis安装到postgres容器中。
Dockerfile:

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:

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

我收到此错误:


错误:无法满足的约束:
postgresql-9.6-postgis-2.4(缺失):
所需者:
world [postgresql -9.6-postgis-2.4]
postgresql-9.6-postgis-2.4-scripts(missing):
需要者:
world [postgresql-9.6-postgis-2.4-scripts]
命令'/ bin / sh -c apk更新&& apk添加-u postgresql-9.6-postgis-2.4 postgresql-9.6-postgis-2.4-scripts&& rm -rf / var / lib / apt / lists / *'返回了非零代码:2

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

我发现了类似的问题,例如as:

I found similar questions such as :


  1. 错误:无法满足的约束:在高山

  2. 错误:约束条件不令人满意-在php:7-fpm-alpine上

  1. ERROR: unsatisfiable constraints: while installing package in alpine
  2. ERROR: unsatisfiable constraints - on php:7-fpm-alpine

但是它不能解决我的问题。如何使用apk将postgis扩展名添加到我的postgres容器中?

But it doesn't solve my problem.How can I add postgis extension to my postgres container with apk?

推荐答案

Postgis 软件包仅在边缘高山仓库中可用,而不是稳定的。这就是为什么您收到无法满足的约束错误的原因。

Postgis package is only available in edge alpine repo, not in a stable one. That's why you are getting "unsatisfiable constraints" error.

但是无论如何,您都可以从边缘仓库中安装 postgis

But anyway you can install postgis from edge repo:

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

# apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
WARNING: This apk-tools is OLD! Some packages might not function properly.
v3.5.2-254-g9d4623dc57 [http://dl-cdn.alpinelinux.org/alpine/v3.5/main]
v3.5.2-247-gc85efb30e1 [http://dl-cdn.alpinelinux.org/alpine/v3.5/community]
v3.7.0-2163-ge03552fc58 [http://dl-cdn.alpinelinux.org/alpine/edge/testing]
OK: 10930 distinct packages available

# apk search --no-cache postgis
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
WARNING: This apk-tools is OLD! Some packages might not function properly.
postgis-dev-2.4.1-r1
postgis-2.4.1-r1
postgis-doc-2.4.1-r1

因此,最终的 Dockerfile 是:

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

于2020年1月23日更新:

Postgis : / p>

Postgis is available in main and community repositories starting from Alpine version 3.11:

/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.3
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
/ #
/ # apk search --no-cache postgis
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
postgis-3.0.0-r1
postgis-doc-3.0.0-r1

您不需要使用edge高山vers回购测试分支离子3.11及更高版本。

You don't need to use edge repo testing branch for Alpine version 3.11 and later.

这篇关于错误:在dockerfile中使用apk无法满足的约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆