【发布时间】:2017-09-30 15:25:34
【问题描述】:
我正在尝试使用 plpython 安装 PostgreSQL dockerised 服务。我能够成功构建映像,但是当我运行容器时,出现以下错误:
错误:无法打开扩展控制文件 “/usr/share/postgresql/9.5/extension/plpython3u.control”:没有这样的文件 或目录声明:创建扩展“plpython3u”; psql:/docker-entrypoint-initdb.d/create_db.sql:7: 错误: 不能 打开扩展控制文件 “/usr/share/postgresql/9.5/extension/plpython3u.control”:没有这样的文件 或目录
我的目录布局:
me@yourbox:~/Projects/experimental/docker/scratchdb$ tree
.
├── Dockerfile
└── sql
├── create_db.sql
└── schemas
└── DDL
└── db_schema_foo.sql
Dockerfile
FROM library/postgres:9.6
FROM zitsen/postgres-pgxn
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 postgresql-plpython3-9.6
RUN pgxn install quantile
COPY sql /docker-entrypoint-initdb.d/
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
# Set the default command to run when starting the container
# CMD ["/usr/lib/postgresql/9.6/bin/postgres", "-D", "/var/lib/postgresql/9.6/main", "-c", "config_file=/etc/postgresql/9.6/main/postgresql.conf"]
create_db.sql
# Uncomment line below for debugging purposes
set client_min_messages TO debug1;
CREATE EXTENSION "quantile"
CREATE EXTENSION "plpython3u";
-- Create myappuser
CREATE ROLE myappuser LOGIN ENCRYPTED PASSWORD 'passw0rd123' NOINHERIT;
CREATE DATABASE only_foo_and_horses WITH ENCODING 'UTF8' TEMPLATE template1;
-- \l+
GRANT ALL PRIVILEGES ON DATABASE only_foo_and_horses TO myappuser;
-- Import only_foo_and_horses DDL and initialise database data
\c only_foo_and_horses;
\i /docker-entrypoint-initdb.d/schemas/DDL/db_schema_foo.sql;
-- # enable python in database
[[编辑]]
这些是我用来构建和运行容器的命令:
docker build -t scratch:pg .
docker run -it -rm scratch:pg
如何在 dockerised PostgreSQL 服务中安装 plpython?
【问题讨论】:
-
乍一看,它看起来像是一个版本混淆:
FROM library/postgres:9.6vs/usr/share/postgresql/9.5/(注意 9.5 9.6) -
@FrankSchmitt 是的,我也注意到了。但是修改路径似乎并不能解决问题,并且有一次我在我的 Dockerfile 中使用了 PostgreSQL 9.5 映像 - 在所有这些更改中都存在错误 - 所以我猜它一定是不同的东西。
-
@HomunculusReticulli 你有没有找到解决办法?
标签: postgresql docker