A lot of times when I talk to people about Docker, they will say “Oh, like a lighter VM?”. And of course, my reaction is:
Sure, they both run isolated environments, but VMs and containers are dissimilar when it comes to their basic structure. Calling a container a “light VM” may seem like an easy comparison to make, but the two are very different.
As we saw in my first Hello Whale article, I love a good visual example. So, here we go!
A snack bar has to have a lot of things to operate. You need a stand, inventory, a cash register, and any other items you may need (napkins, sprinkles, Nutella, etc.). You also need employees to run the stand, and at least enough space for 1-2 workers to be inside it at all times. So the smallest stand you can get will have to be minimum 5x5x7 feet to fit your employees in it. You may realize over time, you only need 1 employee, so you fire one of them. Then you might realize people don’t like sprinkles after all, so you put away your sprinkles under the counter. You now have more space than you need, and a lot of extra things you may not be using. To get your artisan handmade banana on a stick snack, you’ll need all of these things.
Vending machines are totally different. We can have sodas, candy, cookies, gum, Scantrons; all in one small machine. We don’t need any employees, so the size and amount of materials are much less than that of a snack bar. Inside, all of the machinery is shared- meaning all snacks operate under 1 machine. Any time someone gets a snack, they get just that. If I want a banana similar to one at the stand, I can select 1 banana, and one packet of Nutella, put them together, and have one just like the one on the stand. Separate pieces coming together (without anything extra). Additionally, as the owner, you can also choose to have a larger vs. smaller machine (depending on your needs).
To be fair, there are some similarities between the two, but they are two completely separate things. Bret Fisher broke this down perfectly in his Udemy class. He mentions “they are just processes”, “limited to what resources they can access”, and they “exit when process stops”. With containers, you will not need a full operating system- you only get what you need.
Additionally, Docker helps you automate the process of configuring your development environment. Not only is running your app much easier- but sharing becomes much easier. When first setting up my machine and running my app in my early days of learning to code, I remember thinking to myself “there has to be an easier way to install this stuff”. Turns out, Docker is the answer. I encourage anyone looking to speed up their build/test/run processes to give containers a chance (and use Codefresh while you’re at it to help automate it all!).
Until next time!