Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker - extend the parent's ENTRYPOINT

I've got a custom image based on the official postgres image and I want to extend the entrypoint of the parent image so that it would create new users and databases if they don't exist yet every time a container starts up. Is it possible? Like my image would execute all the commands from the standard entrypoint plus my own shell script.

I know about putting my own scripts into the /docker-entrypoint-initdb.d directory, but it seems that they get executed only when the volume is created the first time.

like image 307
super.t Avatar asked Sep 26 '17 17:09

super.t


Video Answer


1 Answers

What you need to do is something like below

setup_user.sh

sleep 10
echo "execute commands to setup user"

setup.sh

sh setup_user.sh &
./docker-entrypoint.sh postgres

And your image should use the ENTRYPOINT as

ENTRYPOINT ["/setup.sh"]

You need to start your setup script in background and let the origin entryscript do its works to start the database

like image 61
Tarun Lalwani Avatar answered Sep 19 '22 01:09

Tarun Lalwani