4 ms·
>> I think part of the problem is that composition of images is strict "subclass"-type inheritance, so they don't compose easily. This does seem like a pretty
by ollysb 12y ago
>> I think part of the problem is that composition of images is strict "subclass"-type inheritance, so they don't compose easily.
This does seem like a pretty major limitation, is this a fundamental constraint or is it something that might be fixed in the future?
- zaroth 12y agoThe "subclass"-type inheritance is due to the underlying union filesystem (AUFS). Each command in the Dockerfile is applied as a layer and then cached, and each resulting image can be referenced as a starting point from another Dockerfile. So you can branch out from a common base image, but you can't somehow co-mingle multiple parent images into one child. If you think about it like the filesystem giving you a snapshot at each line of the Dockerfile, you can see how inheriting from a single snapshot is trivial, but somehow inheriting from multiple snapshots into one would require much more awareness in order to merge them. The practical effect is that either you build a more one-size-fits-all "base" image which you reference for all your services, or you have multiple base images with different more tailored sets of dependencies built up, or you have a very thin base image (e.g. not much more than ubuntu-latest) and just add what you need inside each individual Dockerfile. I ran into the same issue at first when laying out the Dockerfile hierarchy for all my services/roles, but I think in this case it actually falls under "less magic is better" / KISS. Dockerfiles are so easy to read and write once you get going, you won't mind the simplistic approach.
- ollysb 12y agoIt sounds like you need something else to help you build the dockerfiles then i.e. I need a dockerfile with nginx, postgres and memcached so I use something like puppet/chef to put it together, is that possible?
- nl 12y agoIt's easy to build new images from Dockerfiles. And "cut-n-paste" based "inheritance" works well when combining two or more Dockerfiles into a single one that has everything you want. But you can't use composition to combine the actual downloaded images themselves. Using Chef within Docker to build up the services is documented on the Docker site[1], and of course puppet or whatever is essentially the same. [1] http://docs.docker.com/articles/chef/ http://docs.docker.com/articles/chef/
- vidarh 12y agoMy personal opinion is that if you think you need a Dockerfile with nginx, postgres and memcached, you're still thinking in terms of VMs. To me, that is three containers.