'Is it possible to split a layer of an existing docker image?

Part of creating a docker image includes running a product install. This product install creates a thick layer of over 10GB. Having such a thick layer creates challenges when pushing the image to the repository. Is there a way to break down an existing image layer into multiples? More specifically, expand the layer on the filesystem, and then create new layers based on subfolders?



Solution 1:[1]

I ended up doing the following:

  1. Run the base container
  2. Using exec, installed the product fully in the running container.
  3. Moved a very large folder to a mounted volume, making the core smaller.
  4. Making a snapshot of the running container into an image.
  5. Running the new image.
  6. Restoring the removed folder from the mounted volume.
  7. Captured the running image as the final production image.

The above has helped me to turn a 12GB layer into two of 6GB and eliminate issues that I faced when pushing a very thick layer of 12GB.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user1015767