postgresql - docker-entrypoint.sh忽略/docker-entrypoint-initdb.d/my.backup

标签 postgresql docker

我正在尝试使用以下方法初始化运行Postgres的容器

FROM postgres:9.6

COPY my.backup /docker-entrypoint-initdb.d/
在我的Dockerfile中
当我运行时,输出为:
root@pc ~ % docker run  -p 5432:5555 -e POSTGRES_PASSWORD=postgres 

The files belonging to this database system will be owned by user "postgres". This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default timezone ... Etc/UTC selecting dynamic shared memory implementation ... posix creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok

Success. You can now start the database server using:

pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....LOG: database system was shut down at 2020-10-09 00:41:58 UTC LOG: MultiXact member wraparound protections are now enabled LOG: database system is ready to accept connections LOG: autovacuum launcher started done server started

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/my.backup


我已检查文件权限
如何确定初始化脚本为何忽略备份?

最佳答案

如果my.backup是一个shell脚本,则需要给它加上.sh扩展名。从the documentation:

If you would like to do additional initialization in an image derived from this one, add one or more *.sql, *.sql.gz, or *.sh scripts under /docker-entrypoint-initdb.d (creating the directory if necessary). After the entrypoint calls initdb to create the default postgres user and database, it will run any *.sql files, run any executable *.sh scripts, and source any non-executable *.sh scripts found in that directory to do further initialization before starting the service.

关于postgresql - docker-entrypoint.sh忽略/docker-entrypoint-initdb.d/my.backup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64272501/

相关文章:

maven - 如何使用fabric8-maven-plugin标记图像?

sql - 如何使用 postgres 中的窗口函数选择特定更改

mysql - Talend 将 JSON 字符串转换为 PostgreSQL 中的 JSON 或 JSONB

python - 无法使用pydevd-pycharm连接到远程调试服务器

node.js - 错误 : EACCESS: permission denied, 打开 'build/FILENAME.js'

.net - 在 docker 容器上安装 msi

postgresql - 从 Slick 中的 PostgreSQL 扩展添加数据类型

postgresql - 如何在其中包含多个值的 PostgreSQL 函数中创建参数?

postgresql - PostgreSQL 的 GUI 工具

docker - Docker如何保持镜像不可变