Docker: How to create a stack, several images or one basic image?

I'm new to Docker, and I have doubts about using a single image database for my stack, or should I define each image based on my needs.
For example, after reading a blog about creating a website using docker, the author suggests the following stack: enter image description here

Image taken from http://project-webdev.blogspot.de/2015/05/create-site-based-on-docker-part4-docker-container-architecture.html
Now let's look at the structure. If we have basic images in the Docker registry for technologies such as mongoDB, io.JS, nginx, why in these examples we do not use these images that do not use one basic Docker image for everything?

+5
source share
2 answers

I am the author of this blog / series, so let me tell you in detail about why I chose one basic image. :)

Docker offers the ability to use a common base image for subsequent images, so you can add all the images, and each image contains only diff for the main image (which is a big advantage of docker!). You can save disk space and RAM. If this does not bother you (I mean that RAM and memory are cheap), you can also use multiple images.

Another advantage of a single base image is that you can customize / protect this base image based on your needs. If you use a different base image for each container, you must support all of them (for example, a firewall), and Docker will load several different images (uses more disk space, collecting containers takes longer)).

But what's the difference when you look at official images? The official images of mongodb, redis and MySQL are based on the debian: wheezy image. So, if you use these images, they will also be based on the same base image, right?

Anyway, if you want to use your own architecture, feel free to ... please think of this architecture / blog as a possible idea for creating a Docker setup. Thanks to Docker and how it splits the kernel, you can use as many images as you want. :)

Hi,

Sasha

+5
source

I suppose it depends on the application, but in this case you are right, it makes no sense to have a large base image.

In my opinion, the author created the base image, and then built many other images from this base image. When you create an image for dockers, many intermediate images are created, so if the base image is the same, it can be shared and potentially save some memory on your computer.

but I don’t think it matters when you start the containers. each container is independent, and they essentially only use the linux kernel. and actually it’s really bad, because the base image in this case is huge and requires a lot of resources to create a container from an image like this. the dedicated images for each service are much smaller and take up much less resources when you start containers with them. so any memory that you could save from creating a large base image would not be worth it.

+1
source

All Articles