How to flatten an image with 127 parents

You can flatten an image with docker export and then docker import. That will take all the existing layers and export them as a single file system image, in a tarball. Then import will bring it back in again as an image.

Steps:

  1. docker run --name mycontainer the image to create a container (the container name mycontainer is just an example)
  2. docker export --output=mycontainer.tar mycontainer the container to a tarball (mycontainer.tar is just an example)
  3. cat mycontainer.tar | docker import - mynewimage:imported the tarball (the image name mynewimage:imported is just an example)

Docs: