Simple Docker for development

24 May, 2019

I have gone through a few stages of development environments when working on my own projects and at work. When I first started working at Weddingstar we setup our development machines to mimic what we were running on the server. This meant that when our live servers were running on Ubuntu 14.04 that is what we had on our dev machines. We did this to make sure there were limited changes between our dev environment and the live server, to avoid the well it worked on my machine. Then when we moved our servers to Ubuntu 16.04 that is when we upgraded our computers. This worked ok and still does for some of our developers. It just means that we can't upgrade or development machines to a newer OS or something completely different from Ubuntu.

Vagrant

This is where I started using vagrant and running virtual machines. This worked fairly well. It meant that I could run whatever OS I wanted to develop on, as the code would run in a virtual machine with the proper operating system and software. It also made it easy to bring up new VMs to test different environments when upgrading software. There were just a couple issues with this. One is that is was a little slower than running the site right on the host OS, and it would sometimes make it difficult to syncing files quickly between the host machine and the VM.

Docker

That is when I decided to give docker a try. So I started reading documentation and playing around with it. I read article after article on how to setup a docker environment, it looked so easy. Just declare an image and a volume and bam your up and running. When I tried to apply this to my own project I just found frustration. I couldn't find the right images and trying to link everything together never seemed to work. That is when I decided to make things simple and just build up an image that was similar to our production machine. Once I decided to do this it was much easier to follow and build what I needed.

After much struggling to wrap my head around docker and figuring out how to set it up I am very pleased with the results. It gives me what I was looking for. A way to develop on whatever operating system that I wanted but run my code in the right environment, and the speed that I needed to keep moving quickly. One advantage that came later was that I was able to quickly build new containers for different branches that I was working on so that management could look at the changes that I was making while I was working on other branches. More on that in another post.

Setting up a docker Dev environment