Getting shell script to run post service startup

Hello,
I’m seeking some docker advice. I’m using the mysql 5.6 docker image from docker hub. What I’m trying to accomplish is having a shell script execute post the startup of the mysql service. This shell script will do various tasks such as create database users, import some data, run database migrations with flyway, etc…

At the moment I have a Dockerfile that imports the mysql 5.6 image and installs a few additional dependencies. I’ve also created a shell script which gets copied to the root of the container for execution. My question is, how do I get it to execute after the mysql services has successfully started? I’ve tried running it via CMD or ENTRYPOINT but doing that seems to completely override the base functionality of the docker image. I’ve also tried to execute the original docker-entrypoint.sh file from within my shell script but I’ve had little success with that as well.

Any pointers would be much appreciated!

Thanks

You should read the mysql image documentation, especially the subsection entitled “Initializing a fresh image”.

As a general rule, you don’t; you could start a second container that tried to reach the first one. You can read through the mysql entrypoint script to get an idea of the kinds of gymnastics that would be involved.