简体   繁体   中英

Import database in creating docker container - need use pg_restore

Has someone solved the postgre database auto import when creating a docker image ? The traditional method is to put files into the docker-entrypoint-initdb.d . But, it does not work for me, because I need to import via pg_restore (because of custom-format dump). I do not know how to start postgres service through dockerfile . The problem is that every time it runs in a separate container layer. Thank you for your help.

I solved this by put .sh script(which contains pg_restore commands) to docker-entrypoint-inidb.d. I use official Postgre image, which runs after dockerfile any .sql and .sh files, which are in docker-entrypoint-initdb.d More info https://github.com/docker-library/docs/tree/master/postgres#how-to-extend-this-image

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