Reputation: 2153
I'm new to Docker. I've been trying to figure out how to "combine" multiple Docker images but I can't seem to find a straight answer. I've read on SO that adding multiple FROM statements is possible but discouraged.
For example, I want an image that features NGINX and MongoDB. Should I just copy-paste the contents of their official dockerfiles into one? What is the recommended way to combine them?
Upvotes: 2
Views: 318
Reputation: 66817
While it makes sense to combine some services, e.g. nginx and a server-side script toolset, I would recommend against mixing a nginx and a mongodb container.
Instead, use each service in its own container and link the containers. To ease the process, I highly recommend reading up on docker-compose in order to build a stack.
Upvotes: 2
Reputation: 5508
Docker uses single inheritance rather than composition. And that is one of the missing features as for me.
That being said you should rarely need it at all, as you should run 1 thing on 1 container. So in your cases I would advise to use 2 images.
If you really need to run it on one, I would suggest to copy-paste configuration that makes NGINX installed on MongoDB base image or vice versa. Then add supervisord to run both
Upvotes: 1