我正在尝试使用以下方法初始化运行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/