简体   繁体   中英

docker-entrypoint.sh ignoring /docker-entrypoint-initdb.d/my.backup

I'm trying to initialise a container running Postgres using

FROM postgres:9.6

COPY my.backup /docker-entrypoint-initdb.d/

in my Dockerfile

When I run, the output is:

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

I've checked file permissions

How can I determine why the init script is ignoring my backup?

If my.backup is a shell script, you need to give it .sh extension. From 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM