Over-riding ENTRYPOINT using docker run

Rachit Jain
Oct 26, 2020

Overriding docker ENTRYPOINT can be a little confusing and I thought of writing out this short piece to help all the people (like me) who got stuck doing it.

Suppose you have your docker image with ENTRYPOINT ready and now want is to run it using `docker run`. It is very straightforward and you can do something like below.

But what if you want to use the same docker image to run multiple scripts in different iterations. Suppose in some cases you want to run model_training.sh and in some cases, you want to run model_predictions.sh. How do you do that?

One way to tackle this is by overriding the ENTRYPOINT. Overriding the entry-point can get a little overwhelming because of a lack of proper documentation regarding this that I could find. I'll present it in a very simplified way.

Your common docker file can look something like below

To override the ENTRYPOINT, your docker-run command would change and would have some added lines.

Note that in the above docker run command we have added an additional argument “entrypoint” which is followed by the command to run in double-quotes.

After the “image-name”, you specify the script to run along with any additional parameters without quotes.

And that is it. Simple as that! You are one step closer to becoming an expert in using Docker!

Photo by Vasily Koloda on Unsplash

I hope this helps you!

--

--

Rachit Jain

Data Scientist | Recommendation Systems | NLP | I travel and sometimes write about it!