Why I Got Started with Docker
I'm a very pragmatic developer and only jump ship to new technologies when I see a big benefit. Here's what drove me to use Docker.
Back in 2012, I was investing heavily in Virtual Machines because I was spending most of my days writing Ansible playbooks to help automate deploying web apps for both myself and my clients.
If you don’t know what Ansible is, that’s ok. For now just think of it as a magical tool that lets you write down some rules which dictate what files and services should be on a server, and then after running Ansible, your server will be configured based on the rules you wrote.
There’s a lot more to Ansible but it’s not important to understand it for this story.
My goal was to figure out a work flow on my development machine which let me spin up brand new servers to run my Ansible playbooks against. This way I could be confident that my Ansible code worked because they were well tested.
By the way, Docker has a number of other interesting use cases too. It’s not just for “ops” people. If you’ve ever had difficulty setting up your development environment then Docker can make your life about a billion times better. It definitely improved my overall productivity as a developer.
Virtual Machine Woes
Anyways, this is when I started to use Virtual Machines. Virtual Machines let you run your code in fully isolated environments that are independent of your main operating system.
You can think of a VM as a computer with an operating system running on it, except instead of being real hardware or having to dual boot, it’s virtualized hardware done at the software layer. Hence, it’s a Virtual Machine. If you’re curious, I wrote a more detailed article which compares Virtual Machines to Docker containers.
The idea here is, I could be running my main operating system, and just spin up a Linux Virtual Machine as a test bed for my deploy scripts written in Ansible. These deploy scripts would install things like my database server, set up my web application, start a web server such as nginx, configure a firewall and so on.
In between tests, all I had to do was destroy the Virtual Machine and make a new one, but this work flow was very tedious and I was wasting so much time between tests. Each time I destroyed and created a new Virtual Machine it would take minutes, and sometimes it only took 10 seconds to write the Ansible code I wanted to test.
Coding for 10 seconds and then having to wait 3 minutes to see the change is a very destructive development loop. You’re constantly waiting on your computer to finish something while your mind drifts onto other topics such as wondering what your elbow smells like.
Yet I was stuck doing this for a very long time.
Raw Linux Containers
That is until I started to use raw Linux containers or LXC for short. Linux containers existed long before Docker and if you’re a trivia fan, earlier versions of Docker were using Linux containers under the hood.
The problem with using LXCs manually is that it’s very complicated. There’s all sorts of template files, configuration parameters and command line tools that you need to use to get everything running. It’s a very brittle system. Also, as the name implies, it only runs on Linux.
However, once it was all set up, it was a pretty big improvement over Virtual Machines for my use case. I was able to set up test cases to run my Ansible scripts in isolation much faster than before. What took minutes with VMs took only seconds with LXCs.
Now, there were a bunch of weird edge cases and looking back, I wasn’t really using Linux containers in a “proper way”. This mainly stemmed from me thinking they were lightweight Virtual Machines.
I actually didn’t know what the heck they were under the hood. I just blindly followed some blog posts without looking into things on my own too deeply.
Docker Offered Something Better
Long story short, I was using Linux containers for quite a while and eventually Docker picked up enough steam that it caught my eye. I noticed that it offered similar benefits to Linux containers, and so much more.
I also realized how little I knew and how much better things would be if I embraced the Docker ecosystem and its philosophy on how to isolate a running process.
It was a complete mind blowing experience where it felt like everything I knew about web application development and deployment was flipped upside down (for the better).
So, now you know why I started using Docker and have stuck with it ever since. By the way, I still use Ansible too but now I use it in a different way.
What got you interested in Docker?