我正在尝试使用 Alpine
图片照顾一些Postgres
数据库创建/准备。
在容器内,我正在运行以下命令:
createdb -e -O ${DB_USER} ${DB_NAME}
psql -e -d ${DB_NAME} -c "CREATE EXTENSION postgis;"
第一行工作正常,但第二行不行。
我已经用两个 docker 构建尝试过这个:
FROM alpine:3.6
RUN apk add -U postgresql
COPY ./db-creator.sh /db-creator.sh
CMD ["./db-creator.sh"]
这张图片给了我以下错误:
CREATE EXTENSION postgis;
ERROR: could not open extension control file "/usr/share/postgresql/10/extension/postgis.control": No such file or directory
我没有尝试安装
PostGIS
直接作为某人在 this forum坚持说apk add -U postgresql
裸机 Alpine
图像应该足够了。FROM postgres:9.6.4-alpine
RUN apk add -U postgresql
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk update && apk add -u postgis
COPY ./db-creator.sh /db-creator.sh
CMD ["./db-creator.sh"]
我添加了最后两个 RUN 语句以遵循所提到的 here .在这种情况下,我无法直接安装
PostGIS
并得到以下错误:fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/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.6.5-44-gda55e27396 [http://dl-cdn.alpinelinux.org/alpine/v3.6/main]
v3.6.5-34-gf0ba0b43d5 [http://dl-cdn.alpinelinux.org/alpine/v3.6/community]
v20200117-229-g073aaff70d [http://dl-cdn.alpinelinux.org/alpine/edge/testing]
OK: 12520 distinct packages available
WARNING: This apk-tools is OLD! Some packages might not function properly.
postgis (missing):
ERROR: unsatisfiable constraints:
required by: world[postgis]
到底怎么样:)),我可以使用
PostGIS
与 Alpine
图片?我是否需要使用其他镜像版本或安装 PostGIS
不一样?
最佳答案
如 documentation 中所述, 附加扩展部分:
When using the Alpine variants, any postgres extension not listed in postgres-contrib will need to be compiled in your own image (again, see github.com/appropriate/docker-postgis for a concrete example).
对于基于 debian 的这里是 docker 镜像:
https://github.com/appropriate/docker-postgis/blob/f6d28e4a1871b1f72e1c893ff103f10b6d7cb6e1/10-2.4/Dockerfile
如果您想将 Postgis 与 PostgreSQL Alpine 图像捆绑在一起,您已经构建了它。
关于postgresql - 无法在 Alpine 图像上使用 PostGIS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59862229/