(I typed quite a bit, then lost it all when dockerhub timeout on me! Iāll be brief this time. Yeah Iāll write in a editor first, but Iāve wasted some time alreadyā¦)
Iāve iterated over a hierarchy of Python images, like
base --> data --> modeling --> visualization --> extra
each image adds some more libs (both Python and linux) on top of the prev image.
ābaseā contains (in additional to thing you expect) vim, debugger, profiler, py.test (running unit tests).
āextraā contains documentation generation systems (Sphinx) and other things that do not really pertain to ārunningā the programs.
Say project A needs image āmodelingā. I define a script to launch this image for development. Important: ādocker runā has many options you can use to customize the environment without building a customized physical image. I map the source code volume into the container, so that I get the benefit of interactive editting both inside and outside of container (using IDE and other heavy weights) and testing right away.
Meanwhile, I define a script to build a production image and create production launch scripts and so on. The production image starts with āmodelingā, but also freezes my source code in the image (for the case of Python, I donāt need to install). Paths, directory structures and so on guarantee the dev and production environments are really identical, except that for dev, the source code is a mapping of ourside, whereas for production, the source code is embedded inside.
So, ābaseā enters production images whereas āextraā does not.
I may have project B based on image ādataā, projct C based on image āvisualizationā, and so on.
Of course this single lineage of images canāt serve all my projects, but it supports quite a few.
I value a smaller number of images much more than a large number of images individually customized and optimized. I do tweak the images often, so the number matters alot I guess. While trying to avoid bloat, I donāt obsess with removing a couple hundred megabytes of extra size, if that necessitates maintaining a separate image.