Using Docker for Development
Docker has transformed the way we package and ship applications. But. did you know it can transform your development setup too?
Stop me if you’ve heard this one before: You get a new computer. As you’re setting it up, you swear on Turing’s grave, to only install the bare essentials on it and avoid bloatware at all costs. Fastforward a couple of months, you have the Java JDK, Go tools, multiple versions of Python and the Android SDK (for that side-project app you might someday resume developing) installed on your machine.
Docker to the rescue
That’s right, you can use Docker to containerize your development environment! This way you avoid installing all that tooling on your host machine, making Docker your only dependency. Now you can develop from any computer, regardless of the OS, as long as it has Docker installed. As an extra benefit, all collaborators of the project get consistent environments, so, no more: “works on my machine”.
I discovered this fighting to setup the env to write this blog on a new machine. After playing “google the exception” for a few hours I though: there has to be a better way of doing this. Using this repo as inspiration I added a
Dockerfile to my project, that creates a Docker image containing all the dependencies needed to run Octopress. Then simply by mounting the project directory on the
/octopress folder I can run all the usual
rake tasks, just as I’d do locally, but on the container.
No more messing around with language environments and dependencies. Build the image, spin up a container, and blog from anywhere.