Recently I have the case where I have to use a base Docker image from a remote or local repository. I love to keep the configuration close and to not have a couple of configuration files with the same content so I decided to write a simple program which will do the config switch and then will return it back (if needed)

Here is an example of usage:

When I build the images locally I want to use:

When I want to build from our CI/CD server I would like to use the remote ECR

Then in the Docker file, I put those lines

And here is how the config is changed to point to the remote-images

and this is how it is changed back to local images.

So far I haven’t found any drawback on this approach. For sure there is some drawbacks please let me know if you hit it.

And here is the code…