How to Merge Two Docker Images

When working with Docker, it is a good practice to search for some ready-to-use images on Docker Hub before building you own. It is very powerful to have your software architecture distributed in a set of containers, each one does one job. An the best building block of your distributed application is to use official images from Docker Hub. You can trust their functionalities.

In some cases, you may want to have one container do two different jobs. In other few cases, you may want one Docker image to contain dependencies from two different Docker images. This is easily done as long as you have the Dockerfile of each image. Simply, organize them in one file and build it!

However, if you spend most of the time using ready images from Docker Hub, you do not have their source Dockerfile. I spent some time searching for a tool to use it to merge (or flatten) two different Docker images; that I don’t have their Dockerfiles. I was searching for something to do the following:

image1 --
            \
             ---> merged_image_12
            /
image2 --

Although this issue was closed before in two different threads (1, 2), it arises in some scenarios when you want to do something like that!..

How to Merge Two Docker Images

Advertisements