PROJECTS NOTES HOME

What is Docker?

In almost every Django chat podcast I hear about Docker. For me it seems like a DevOps'ish kind of tool, but it must be useful to learn for a freelance Django developer like myself. It sounds like an efficient and easy way to deploy Django applications.

1 In the beginning

If you wanted a server to store your applications onto, it had to be a physical server in a data center. It could run ONE operating system(OS). If you wanted another OS - you had to have another physical center! Quite inefficient and most likely expensive.

2 Then came the virtual machines.

  • you would have a server hardware
  • then on the server hardware you install a hypervisor(vmware esxi)
  • inside this hypervisor you then create as many virtual machines as you like, assigning CPU, ram, storage by yourself. Can increase all of these in the future if you need to.

Now you have one physical server and many virtual machines on it. Already way more efficient than the first option.

3 Now what is the docker about?

You still have the hardware, but on top of that you install one OS. Ubuntu for example.

Now you install docker as any other application. It will run as daemon. Docker will virtualize portions of our operation system. In this case - Ubuntu to create containers. These containers also can run a different OS's.

  • own OS
  • own CPU
  • own memory
  • own network

all of it is isolated - secure. From their(container) point of view - they are their own thing. They might as well be installed on bare metal servers.

4 Benefits of Docker

Why is Docker so fast?

All the OS's, like Ubuntu, Alpine, Arch Linux, CentOS - all of them using the SAME Linux kernel JUST LIKE the Ubuntu does ON WHICH you have installed Docker daemon.

And with virtual machines - every time you deploy a virtual machine - that is another linux kernel.. it also involves the hypervisor, which is kinda heavy, so overall it's just heavy. There are more parts and pieces that have to be running.

Container - much more simple, lightweight, fast.

You can not mix and match windows and linux OS containers on one machine. If you want to run windows docker machine - you must have an underlying windows OS to run it on. Because they share the underlying os or kernel.

5 Why docker?

As developers - we write our app - it works great on our machines. Then we want to either deploy it or run on other machines or give it to a tester - something breaks, does not work.. Having a docker container prevents this mess.

Hey, it worked on my machine!

No more of that junk. If you deploy in a docker container - everything the app needs is contained in the container, it's isolated.

5.1 Microservices

Usually you deploy the WHOLE app inside one container or a VM. For example WordPress. You install WordPress server and MySQL database on the same machine. But what you can do with docker is install wordpress server on one container and mysql database on another. So whenever you want to update wordpress server - you update only just that. Nothing is in a way, nothing is conflicting, mysql database remains untouched. Sounds good, I must try experiment with that.

6 Docker docs