Docker PostgreSQL 9.6 – 安装扩展plpython3u(与分位数扩展冲突)
我想用plpython安装PostgreSQL dockerised服务。 我能够成功地构build图像,但是当我来运行容器时,出现以下错误:
错误:无法打开扩展控制文件“/usr/share/postgresql/9.5/extension/plpython3u.control”:没有这样的文件或目录语句: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
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
[[编辑]]
这些是我用来构build和运行容器的命令:
docker build -t scratch:pg . docker run -it -rm scratch:pg
如何在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
,它不等于只是postgresql
,它正在跳过这一部分。
默认的ENTRYPOINT
应该做你想要的。 尝试删除您的CMD
。
我刚刚从头开始运行,似乎扩展已成功创build。 还有问题吗?
/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.
- 将字典文件添加到postgresql docker容器
- JAR在本地工作,但在Docker容器(Apache-POI)中挂起失败
- docker是否支持类似于Git别名的命令别名?
- System.InvalidOperationException:“path基础只能使用IApplicationBuilder.UsePathBase()configuration。
- Dockerconfiguration在运行时编辑节点代码
- docker容器连接本地postgresql
- (gcloud.preview.app.deploy)意外的错误。 部署版本
- 连接到centos7泊坞窗图像上的mongodb
- 我正在尝试构buildDocker postgres映像时遇到错误