Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Save Yourself from Years of Turmoil by Using Docker Today

blog/cards/save-yourself-from-years-of-turmoil-by-using-docker-today.jpg

Understand the problems Docker solve and how it will potentially save you years of headaches by following a time-line of a fictional developer.

Quick Jump: This Article Is Written From the POV of a Fictional Person | Table of Contents | Do I Need to Switch Operating Systems? | Time for a New Laptop | Which Linux Distro Should I Use? | Time to Install Rails So I Can Code My Rails App | My App Needs a Database | My App Needs Redis | Wait, Virtual MacHines Are Actually Good? | Back to the Drawing Board | My Friend Told Me to Try Vagrant | Vagrant Is a Steaming Pile of Garbage | I Want to Show the World My App | Switching Web Hosts | Configuration Management Tools | Deploys Occasionally Fail for Uncontrollable Reasons | My Website Just Got Hacked | It's Been a Long Road and I Want to Help My Friend | Is There a Better Way? | Informing My Friend of Docker | Converting My Rails App to Use Docker | Docker Works in Production Too | How Could I Have Saved All That Time With Docker? | Docker Takeaways

So, you’re either a web developer or are looking to become one and you have a million questions and uncertainties about how to set up your development environment or host your applications in production – I get it.

This article is going to unwind a time-line of a fictional person who is new to web development. It will cover both development and production scenarios.

By the end of the article you’ll understand what problems Docker solve and how it will potentially save you from years of headaches.

Nearly everything you’re about to read is based on real world personal experience and most of it applies to all programming languages.

This Article Is Written From the POV of a Fictional Person

While it will be written in the first person, I will interject my own comments occasionally in italics. I will also estimate the amount of time someone would spend while figuring out a specific topic.

Here’s the back story of our fictional hero:

It’s been a long journey but after months of hard work you’ve gotten to the point that you’re ready to create your first web application.

You know just enough Python and Ruby to be dangerous but you haven’t gotten around to setting anything up yet. You’re just about to start your adventure.

Up until now, you’ve learned everything in a sandbox environment.

Table of Contents

Do I Need to Switch Operating Systems?

Most tutorials I found on Google don’t mention how to set up Python or Ruby, or if they do it’s for OSX but I’m not using OSX. I’m on Windows.

Almost everyone I talk to says Windows sucks for development so I’m not sure what to do. Money is tight and I’m not ready to spend $1,500 on a Macbook Pro.

After hours of Googling I managed to learn about Virtual Machines and installed Linux but I don’t like it, it’s slow and it runs in a small window.

10 hours spent on research

A newbie at this stage in his development career won’t know about things like seamless / unity mode or how to properly configure a VM. If you want to learn how, check out my post on how to create an awesome Linux development environment.

Time for a New Laptop

I’m on a mission to buy a decent laptop to run Linux on. It should be good enough for development but I’m not quite sure what I’ll be running yet.

After trolling Google for hours I managed to find an Acme Inc. laptop for $600. It has 8GB of RAM, an Intel i5 quadcore and an SSD. This looks good enough.

6 hours (16 total) spent on research and spent $600

Which Linux Distro Should I Use?

I blindly followed a VM tutorial from before which installed Ubuntu but what else is there? I don’t want to have to format again later on if there’s something better.

10 hours (26 total) spent on research

It looks like xubuntu is pretty nice. It uses less resources than Ubuntu and installing things on it is compatible with Ubuntu. I’m sold.

xubuntu is finally installed and configured in a reasonable way. Time to tweet about how I’m now an official Linux user. YES!

6 hours (32 total) spent on research

Time to Install Rails So I Can Code My Rails App

Time to crack open Google and figure out how to do this.

4 hours (36 total) spent on research

I don’t get it. So many people use rvm, but a lot of people also say to try rbenv and then there’s an entire camp of others who say to use chruby.

Jesus christ, all I want to do is code my application. I guess I’ll pick rvm because it’s what most people are saying to do.

If you’re not a Ruby developer, replace these with virtualenv or whatever runtime versioning tool your language uses.

6 hours (42 total) spent on research

Finally, rvm is installed and set up. Man, there’s so many little things about Linux that I’m clueless on. I think I’m in over my head but I’ll continue onwards because it works for now.

My App Needs a Database

The Ruby on Rails crowd really like Postgres, so it looks like I need to run Postgres on my laptop.

2 hours (44 total) spent on research

Yay, Postgres is installed and my Rails application can connect to it. I wonder tho, do I need to always keep Postgres running, even when I’m not developing?

1 hour (45 total) spent on research

Looks like I need to remember to stop the Postgres service when I’m done coding.

My App Needs Redis

My app has a chat component to it and Rails 5 recommends that I use Redis. Now it looks like I need to install Redis.

This should go faster because I have a better idea on how to install things on Linux.

1 hour (46 total) spent on research

Cool, the latest version of Redis is installed and everything is working as planned.

Wait, Virtual MacHines Are Actually Good?

Since I have a laptop, I’ve been hanging out at Starbucks recently and also grew a mustache. While twirling my mustache I came across this article and it changed my opinion on VMs.

Luckily it’s only been 2 weeks, and the laptop can still be returned but I need to put Windows back on it.

2 hours (48 total) spent on research

Finally got Windows back on it, and it’s been shipped back. They told me I’ll get my $600 returned in about 10 days. Whatever, that works for me.

Back to the Drawing Board

I know what I want to install, but now I need to do it again. Hopefully I can crank this out quickly.

I just need to find the posts I followed before because I don’t remember all of the commands I ran the other day.

6 hours (54 total) spent on research

xubuntu is now running in Unity mode with vmware and my Rails app is back to working. This is so much better than before, I wish I knew this earlier.

My Friend Told Me to Try Vagrant

He mentioned how Vagrant is the future and that I should be using it instead of my current approach because it will let me share my set up with other developers.

Honestly, I don’t care about that right now. I mean, my set up is working well but I’ll try Vagrant because not future proofing myself sounds scary!

6 hours (60 total) spent on research

I think I understand what Vagrant is now and it does seem like it could be good.

My vmware based set up is great for me, but if I want to create a repeatable environment for others then Vagrant seems like the way to go.

Vagrant Is a Steaming Pile of Garbage

10 hours (70 total) spent on research

I don’t get it. I set up a shared folder but every once in a while my CSS and JS files get garbled and they don’t get updated.

The only way to fix it is to re-create and restart the VM which takes forever. I can’t believe people actually use this software in real life.

I’ve wasted so much time on this. Google says I should try to use something called NFS but it looks like it’s a lot of trouble to get working on Windows.

I’ll give it a shot tho…

4 hours (74 total) spent on research

Well, it’s back to working now and I haven’t gotten any of the CSS/JS issues since but that was brutal to set up.

While we’re at only 74 hours total, it’s not like someone moves through all of this in 74 hours. This is likely 6 months of real life time or more while they figure things out.

I Want to Show the World My App

I’ve given up on Vagrant and spent a lot of time coding my app and now I am ready to show the world the fruits of my labor.

25 hours (99 total) spent on research

The amount of crap I had to research to get my app on a live server was absurd and I barely scratched the surface.

I just blindly followed some tutorial but now I have my app running on a live server. I have no idea if it’s secure, but it works.

During my research I read about Heroku, and this did look a lot easier but it was way too expensive for what I want to do.

Right now my main problem is I have no idea how to update the application.

10 hours (109 total) spent on research

I can update the app now with Capistrano but I really have no idea what I’m doing.

Switching Web Hosts

I just learned that AWS has a free tier and free is better than not free, so it’s time to jump ship.

15 hours (124 total) spent on research

I manually set up the instance on AWS and things are working again but I really dread having to do this again.

I wonder if there are any tools I can use to help me in this department.

Configuration Management Tools

60 hours (184 total) spent on research

It looks like there’s a lot of tools I can use. I read about Puppet, Chef, Ansible and SaltStack.

I spent a lot of time watching video guides, reading tutorials and trying things on my own. It’s hard to say which one I like best.

Ansible had the least amount of complexity and it seems to solve the problem of wanting to create new servers with certain software installed and configured.

Chances are this section alone was months of real life time.

Deploys Occasionally Fail for Uncontrollable Reasons

Well this stinks. Every once in a while when I deploy a new version of my app RubyGems or an apt mirror times out and the entire deploy fails.

I wish there was a way I could somehow package my gems up in such a way that I don’t have to build them at deploy time.

My Website Just Got Hacked

Well, that sucked. I guess my server wasn’t very secure because I woke up today and noticed someone trashed my server.

All of my data is gone, and I can’t even get back into my server. I tried to contact support but it’s been days without a response.

Time to delete my instance and read up on security and backups.

30 hours (214 total) spent on research

I finally get where I went wrong, but my long research sessions have paid off because now I know how to secure my server and perform database backups.

It’s Been a Long Road and I Want to Help My Friend

It’s been well over a year now and one of my friends wants to get into programming.

He is running a Mac and asked me if I could get him situated and at the point where he has Rails installed.

8 hours (222 total) spent on research

It took us all day but we got it running. OSX is so much different than Linux, but on the bright side we got Postgres and Redis running too.

He even likes my app so much that he asked if he could help code it with me once he learns more. I like this idea, but it also reminded me of what my other friend said about Vagrant months ago.

Maybe I’ll open source my app, and other developers will want to contribute. There’s no way I can expect them to spend hours setting up their development environment just to run my project.

Is There a Better Way?

Having being burnt by Vagrant in the past, I would like to find an alternative.

15 hours (237 total) spent on research

There’s this thing called Docker that helps in this area. It allows you to package up an application or service with all of its dependencies into a standardized unit.

I have no idea what this really means but I saw a working demo and it looks awesome.

1 hour (238 total) spent on research

After getting it installed I was able to blindly run commands and spin up a complex example web application in minutes.

It almost seemed too good to be true. It was so easy to install on Linux.

There has to be a catch right? There’s always a catch!

Informing My Friend of Docker

I went to my buddy’s place and told him about Docker. We installed it on OSX together.

2 hours (240 total) spent on research

It wasn’t as easy as Linux and it was definitely different, but it wasn’t bad at all compared to the alternatives.

Converting My Rails App to Use Docker

There was a lot to take in but I converted my app. I’m now able to spin up the entire app in about 2 seconds and shut it down at will.

20 hours (260 total) spent on research

The development experience is awesome and I feel like I can carry this knowledge over to any programming language that I use.

More importantly, my OSX friend was able to get it running well too.

I’d feel very confident pointing other developers to Docker if I decide to open source my app. I just need to solve the production problem now.

Docker Works in Production Too

Well, I’ll be damned. After a long day I had everything “Dockerized” in production, but the big win here is if I changed hosts or had to bring up a new server, I could do it in minutes not hours.

10 hours (270 total) spent on research

More importantly, I can be sure that things will work because all of the dependencies of my app and services have been packed up into Docker images.

How Could I Have Saved All That Time With Docker?

  • I wouldn’t have had to buy a laptop to install Linux on
  • I wouldn’t have had to research Linux distros
  • I wouldn’t have had to research rvm and friends
  • I wouldn’t have had to learn how to install Postgres and Redis directly
  • I wouldn’t have had to spend time learning Vagrant
  • I wouldn’t have spent a ton of time provisioning production servers manually
  • I wouldn’t have had to spend time configuring my friend’s OSX box

  • I would have still likely learned a bit about configuration management
  • I would have still needed to learn about security and best practices

All in all, I would have saved hundreds of hours and months of my life if I had started from Docker from day 1.

Docker Takeaways

Here’s 5 things that Docker will help you with today:

Cross Environment Consistency

Docker allows you to encapsulate your application in such a way that you can easily move it between environments. It will work properly in all environments and on all machines capable of running Docker.

Expand Your Development Team Painlessly

You should not have to hand over a 30 page document to a new developer to teach them how to set up your application so they can run it locally. This process can take all day or longer, and the new developer is bound to make mistakes.

With Docker all developers in your team can get your multi-service application running on their workstation in an automated, repeatable, and efficient way.

You just run a few commands, and minutes later it all works.

Use Whatever Technology Fits Best

If you’re a startup or a shop that uses only one language, you could be putting yourself at a disadvantage. Since you can isolate an application in a Docker container, it becomes possible to broaden your horizons as a developer by experimenting with new languages and frameworks.

You no longer have to worry about other developers having to set up your technology of choice. You can hand them a Docker image and tell them to run it.

Build Your Image Once and Deploy It Many Times

Since your applications are inside of a pre-built Docker image, they can be started in milliseconds. This makes it very easy to scale up and down.

Time consuming tasks such as installing dependencies only need to be run once at build time. Once the image has been built, you can move it around to many hosts.

This not only helps with scaling up and down quickly, but it also makes your deployments more predictable and resilient.

Developers and Operation Managers Can Work Together

Docker’s toolset allows developers and operation managers to work together towards the common goal of deploying an application.

Docker acts as an abstraction. You can distribute an application, and members of another team do not need to know how to configure or set up its environment.

It also becomes simple to distribute your Docker images publicly or privately. You can keep tabs of what changed when new versions were pushed and more.

Free Intro to Docker Email Course

Over 5 days you'll get 1 email per day that includes video and text from the premium Dive Into Docker course. By the end of the 5 days you'll have hands on experience using Docker to serve a website.



Comments