我需要为在 Docker 内部运行的 Postgres 实例创建扩展 - 特别是postgis。我关注了其他 SO 帖子,包括这个帖子,但无济于事。
这是我到目前为止所拥有的...
Dockerfile
FROM postgres
COPY ext-script.sql /docker-entrypoint-initdb.d
ext-script.sql
create extension pgcrypto;
create extension postgis;
码头工人运行命令
docker run -d -p 5432:54323 -e POSTGRES_PASSWORD=somepassword -e POSTGRES_USER=someuser -v postgres-data:/var/lib/postgresql/data --name dbcontainer dbimage
日志
docker logs dbcontainer
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/ext-script.sql
CREATE EXTENSION
2020-02-20 22:18:01.090 UTC [60] ERROR: could not open extension control file "/usr/share/postgresql/12/extension/postgis.control": No such file or directory
2020-02-20 22:18:01.090 UTC [60] STATEMENT: create extension postgis;
psql:/docker-entrypoint-initdb.d/ext-script.sql:2: ERROR: could not open extension control file "/usr/share/postgresql/12/extension/postgis.control": No such file or directory
我错过了什么?
更新
我最终使用了postgis dockerhub 图像。
当您知道如何时,一切都很容易:)
# Dockerfile
FROM postgis/postgis
COPY data.sql /docker-entrypoint-initdb.d