LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Are containers as overprovisioned guests? (https://www.linuxquestions.org/questions/linux-newbie-8/are-containers-as-overprovisioned-guests-4175688177/)

chomwitt 01-07-2021 04:55 PM

Are containers as overprovisioned guests?
 
A story-joke i've heard from a friend:
Quote:

' container technologies remind me of inviting someone in your home and .... surprise he/she comes with not one or two basic luggage (clothes,towels etc) but with his favorite foods, his favorite chair, his favorite bed , his favorite table , his favorite tv etc. And why not his favorite room! '
So without being expert on container , but understanding their basic function i wonder if that jokes contains a truth or not.

berndbausch 01-07-2021 05:22 PM

The idea is that an application container image, such as the ones you find on hub.docker.com, contains not only the application itself, for example a database or a web server, but also a minimal execution environment tailoured to the application. This execution environment is the food, chair, bed, table, TV that the guest brings.

The advantage of bringing the execution environment is the ability to run the container image whereever Docker is installed. Disadvantage: The execution environment makes the container heavier than just running the application on the container host, without containing it. This is the price you pay for containment.

Note that there is another type of containers whose purpose is not encapsulating a single application but providing an almost complete operating system. They are similar to all-purpose virtual machines, but much more light-weight. The Linux Containers, LXD and OpenVZ technologies are in this category.

Sefyir 01-07-2021 07:54 PM

That's a good question, it's yes and no, at least with docker

The default python image is 885MB.
That's a lot! If you were just running

Code:

print("Hello World")
This would be a crazy amount of space.
Let's see how much space that takes (scroll right to see the whole output)

Code:

$ docker container run python python -c "print('hello world')"
hello world
$ docker ps -a --size
929797bb8f82  python        "python -c 'print('h…"  17 seconds ago  Exited (0) 16 seconds ago                                                        recursing_goldberg  157kB (virtual 885MB)

Ok, 885MB + 157KB

This means that when the container ran, it had a virtual size of 885MB and an actual size of 157KB.
Let's create 9 more for a even 10

Code:

$ for i in {1..9}; do docker container run python python -c "print('hello world')"; done
hello world # x9
$ docker ps -a --size
a8f733dffb92  python        "python -c 'print('h…"  5 seconds ago  Exited (0) 4 seconds ago                                                        elated_pare                157kB (virtual 885MB)
69368fa7f82e  python        "python -c 'print('h…"  6 seconds ago  Exited (0) 5 seconds ago                                                        gracious_perlman          157kB (virtual 885MB)
ddcfc455799f  python        "python -c 'print('h…"  6 seconds ago  Exited (0) 5 seconds ago                                                        peaceful_galileo          157kB (virtual 885MB)
34fb4c3beb7b  python        "python -c 'print('h…"  7 seconds ago  Exited (0) 6 seconds ago                                                        tender_edison              157kB (virtual 885MB)
a41ed1a612bf  python        "python -c 'print('h…"  7 seconds ago  Exited (0) 6 seconds ago                                                        charming_galileo          157kB (virtual 885MB)
2aca072f58bc  python        "python -c 'print('h…"  8 seconds ago  Exited (0) 7 seconds ago                                                        upbeat_tharp              157kB (virtual 885MB)
7a79147f19bf  python        "python -c 'print('h…"  8 seconds ago  Exited (0) 7 seconds ago                                                        condescending_hopper      157kB (virtual 885MB)
e3ba41e952d4  python        "python -c 'print('h…"  9 seconds ago  Exited (0) 8 seconds ago                                                        elated_kapitsa            157kB (virtual 885MB)
bd14d06bedd7  python        "python -c 'print('h…"  9 seconds ago  Exited (0) 9 seconds ago                                                        compassionate_archimedes  157kB (virtual 885MB)
929797bb8f82  python        "python -c 'print('h…"  2 minutes ago  Exited (0) 2 minutes ago                                                        recursing_goldberg        157kB (virtual 885MB)

Here's the big question.
Are we using 8.5GB + 1.57MB, or are we using 885MB + 1.57MB?
Any one of those containers can use anything in that huge image, but if you check, the file size used is only 886.57MB

So yes, they each separately have their own house with a couch food etc.. But in a sense they're sharing the same house too and only take the space of a single house.


All times are GMT -5. The time now is 06:14 AM.