在 docker 容器中创建 postgres 扩展
Create postgres extension in docker container
我正在尝试使用以下 Docker 文件在 Docker 容器中创建一个 postgres 实例。
FROM postgres
ENV POSTGRES_DB dspace
ENV POSTGRES_USER dspace
ENV POSTGRES_PASSWORD dspace
COPY init.sql /docker-entrypoint-initdb.d/
这是我的init.sql
create extension pgcrpyto
我正在使用 Codenvy 服务 运行 这个容器。初始化时,我看到以下错误。
[STDOUT] server started
[STDOUT] Reading package lists...
[STDOUT] Reading package lists...
[STDOUT] Building dependency tree...
[STDOUT] CREATE DATABASE
[STDOUT]
[STDOUT] CREATE ROLE
[STDOUT]
[STDOUT]
[STDOUT] /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
[STDOUT] Reading state information...
[STDOUT] 2018-02-15 19:17:34.931 UTC [399] ERROR: could not open extension control file "/usr/share/postgresql/10/extension/pgcrpyto.control": No such file or directory
[STDOUT] 2018-02-15 19:17:34.931 UTC [399] STATEMENT: create extension pgcrpyto
[STDERR] psql:/docker-entrypoint-initdb.d/init.sql:1: ERROR: could not open extension control file "/usr/share/postgresql/10/extension/pgcrpyto.control": No such file or directory
请注意,我的解决方案基于以下 post。
以下回购解决了我的问题。看来我需要提供一个 shell 脚本来执行 SQL.
https://github.com/DSpace-Labs/DSpace-codenvy
Docker 文件
# From https://github.com/DSpace-Labs/dspace-dev-docker/tree/master/postgres
FROM postgres
ENV POSTGRES_DB dspace
ENV POSTGRES_USER dspace
ENV POSTGRES_PASSWORD dspace
COPY install-pgcrypto.sh /docker-entrypoint-initdb.d/
install-pgcrypto.sh
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
create extension pgcrypto;
EOSQL
我正在尝试使用以下 Docker 文件在 Docker 容器中创建一个 postgres 实例。
FROM postgres
ENV POSTGRES_DB dspace
ENV POSTGRES_USER dspace
ENV POSTGRES_PASSWORD dspace
COPY init.sql /docker-entrypoint-initdb.d/
这是我的init.sql
create extension pgcrpyto
我正在使用 Codenvy 服务 运行 这个容器。初始化时,我看到以下错误。
[STDOUT] server started
[STDOUT] Reading package lists...
[STDOUT] Reading package lists...
[STDOUT] Building dependency tree...
[STDOUT] CREATE DATABASE
[STDOUT]
[STDOUT] CREATE ROLE
[STDOUT]
[STDOUT]
[STDOUT] /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
[STDOUT] Reading state information...
[STDOUT] 2018-02-15 19:17:34.931 UTC [399] ERROR: could not open extension control file "/usr/share/postgresql/10/extension/pgcrpyto.control": No such file or directory
[STDOUT] 2018-02-15 19:17:34.931 UTC [399] STATEMENT: create extension pgcrpyto
[STDERR] psql:/docker-entrypoint-initdb.d/init.sql:1: ERROR: could not open extension control file "/usr/share/postgresql/10/extension/pgcrpyto.control": No such file or directory
请注意,我的解决方案基于以下 post。
以下回购解决了我的问题。看来我需要提供一个 shell 脚本来执行 SQL.
https://github.com/DSpace-Labs/DSpace-codenvy
Docker 文件
# From https://github.com/DSpace-Labs/dspace-dev-docker/tree/master/postgres
FROM postgres
ENV POSTGRES_DB dspace
ENV POSTGRES_USER dspace
ENV POSTGRES_PASSWORD dspace
COPY install-pgcrypto.sh /docker-entrypoint-initdb.d/
install-pgcrypto.sh
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
create extension pgcrypto;
EOSQL