DEV Community

Cover image for Weigh anchor! What is Docker?
Miguel Varona
Miguel Varona

Posted on

Weigh anchor! What is Docker?

I recently started a journey to unveil the mysteries of Docker. Nowadays Docker has become something you have most likely heard at least once but...what is it?

Docker is a tool that allows you to create isolated containers to run and share your applications.

Why? My code works perfectly fine in my computer!

It sure does! However, production is not going to be run on your computer.

Imagine you are going to deploy your awesome application or share it with a colleage. You start setting things and then you get some random error. "Weird. It worked on my computer".

Now you have to play detective to see what's wrong. Is it a mismatch in the packages' version? Is it some ENV variable with a typo? That's not fun at all!

Docker allows you to put all of these steps into an image that will be used to create isolated and standarized containers.

An image?

An image is a read-only file that tells Docker how to get your app up and running. You can send this file and Docker will know just what to do. No matter whose computer it is.

Oh, ok...but what about containers?

When you ask Docker to use your image and run your app it creates a container. Containers are a lightweight, standalone execution environment which actually runs your app isolated from other containers.

So...is it like a virtual machine?

It's similar but they don't work in the same way.

A virtual machine has it's own OS running on top of the host's OS while a container uses it's host's OS kernel.

That's why containers are a lot less demanding in terms of resources than using VMs. However, this comes with the tradeoff of being less secure in terms of malicious attacks than virtualization.

Something else to have in mind is that since containers use the host system's kernel they won't be able to run directly on a different OS...

What?! But then I can only share my images with others using the same operating system as me!

No need to worry! Docker has it covered. If you are not using Linux as your host OS, Docker will usually use a Linux VM (WSL) to run every container allowing your containers to be available for use in other OSs.

So it actually uses a VM! How is it any better than just using VM then?

It's just a lightweight virtual machine whose OS kernel will be shared by all your containers instead of having one per container, so in the end it's still requires a lot less resources than using a VM approach and allows standarization of the images accross users with different OSs.

We have now covered some of the most basic concepts on Docker and why you should use it.

Thanks for reading this post. I hope it helped you get the grasp of some basic Docker concepts.

Top comments (0)