我正在尝试用plpython安装一个PostgreSQL文档化服务。我能够成功地构建映像,但是当我运行容器时,我会得到以下错误:
错误:无法打开扩展控制文件"/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.sqlDockerfile
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如何在PostgreSQL服务中安装plpython?
发布于 2017-09-30 16:40:01
我认为您的错误是因为最初的错误CMD,它指向了这个图像的PostgreSQL的错误位置(9.5vs9.6)。
但是,我想我已经发现了为什么没有导入SQL的错误。
此映像的默认ENTRYPOINT (at https://github.com/docker-library/postgres/blob/bef8f02d1fe2bb4547280ba609f19abd20230180/9.6/docker-entrypoint.sh)负责从/docker-entrypoint-initdb.d/导入。因为您正在覆盖CMD,而且它不等于postgresql,所以它跳过了这个部分。
默认的ENTRYPOINT应该做您想做的事情。尝试删除您的CMD。
发布于 2017-10-10 06:56:01
我刚刚从零开始运行这一切,似乎已经成功地创建了扩展。还有什么问题吗?
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/create_db.sql
SET
CREATE EXTENSION
CREATE ROLE
CREATE DATABASE
GRANT
LOG: received fast shutdown request
waiting for server to shut down...LOG: aborting any active transactions
LOG: autovacuum launcher shutting down
LOG: shutting down
.LOG: database system is shut down
done
server stopped
PostgreSQL init process complete; ready for start up.https://stackoverflow.com/questions/46504172
复制相似问题