Hom*_*lli 10 postgresql docker
我正在尝试使用plpython安装PostgreSQL dockerised服务.我能够成功构建映像,但是当我来运行容器时,我收到以下错误:
错误:无法打开扩展控制文件"/usr/share/postgresql/9.5/extension/plpython3u.control":没有这样的文件或目录STATEMENT:CREATE EXTENSION"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
Run Code Online (Sandbox Code Playgroud)
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"]
Run Code Online (Sandbox Code Playgroud)
# 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
Run Code Online (Sandbox Code Playgroud)
[[编辑]]
这些是我用来构建和运行容器的命令:
docker build -t scratch:pg .
docker run -it -rm scratch:pg
Run Code Online (Sandbox Code Playgroud)
如何在dockerised PostgreSQL服务中安装plpython?
我认为你的错误是因为最初的错误CMD指向了该图像的 PostgreSQL 的错误位置(9.5 vs 9.6)。
然而,我想我已经发现了为什么没有导入 SQL 的错误。
此映像的默认值ENTRYPOINT(位于https://github.com/docker-library/postgres/blob/bef8f02d1fe2bb4547280ba609f19abd20230180/9.6/docker-entrypoint.sh)负责从/docker-entrypoint-initdb.d/. 由于您正在覆盖CMD并且它不等于 just postgresql,因此它会跳过这一部分。
默认值ENTRYPOINT应该做你想做的事。尝试删除您的CMD.
| 归档时间: |
|
| 查看次数: |
895 次 |
| 最近记录: |