How would you differentiate between Docker vs EC2 image

I am a big fan of docker. I am still learning it and I like it so much already especially with the performance on Linux. I have a question and would like to hear other’s comments. Let’s say I have a micro service to deploy and it requires some dependencies and configuration. docker is a perfect solution for deployment. On the other hand, I think that using a EC2 image is good as well:

  • launch a Linux image.
  • install all the dependencies.
  • configure it.
  • save a snapshot.
  • publish it in the Amazon Marketplace.

What do you think? Besides the coupling with EC2, what are other pros and cons?

Thank you.

1 Like

Using snapshots is one way that companies would prep their deployments prior to Docker. It works, but the process is not as efficient or cost effective.

  • Speed: Launching a new Amazon instance is a lot slower than launching a Docker container (Time=$)
  • Cost: Extra AWS cost in storing your snapshots.
  • Maintainability: Using snapshots for this type of process takes too much time to maintain. Every time you need to make a change, your going to have to launch a new instance, make your changes, then create a new snapshot - When you create a new snapshot, you’ll need to update your deployment tools to use the new AMI ID. It’s not so bad when it’s only one or two, but dozens/hundreds…
  • Code creep: It’s hard to track the changes you’ve made to your snapshots. Especially if there is more than one admin making changes over several months/years.
2 Likes

Thank you, Jerry. Your answer is very useful.

I’ve been using Docker on EC2 for the past year now. I agree with most everything that Jerry said. The biggest problem I have with AMI snapshots is that you loose visibility of what’s actually in the AMI. Try doing a diff between versions 1.0 and 1.1. This is where the Dockerfile provides a lot of visibility into what your app is composed of.

We use Amazon’s CloudFormation to provision our AWS infrastructure and the application. We CloudFormation to capture everything from IAM roles, security groups, Route53 entries, etc… But provisioning the application is where things get funky with CloudFormation. CloudFormation helped us have more visibility into what was in the application, but as an application configuration tool, CloudFormation kind of blows. It’s probably a great example of when NOT to use JSON for as configuration format, and I’ll leave that :slight_smile:

I started using Docker as a means decouple the application configuration from CloudFormation. The other benefit of this is that I could also run my application in a container on my desktop using Boot2Docker. This made local development and testing easier. There really isn’t an equivalent to Boot2Docker in the EC2 space. Now all my CloudFormation stack has to do is pull and run my containers and my CloudFormation template is much cleaner as all of app-level configuration is captured in the Dockerfile.

2 Likes

Hi, I am completely new in Docker. Try to understand it.
I have a web app in AWS EC2 and its scale with autoscaller service provided by AWS. So when load increase a new EC2 will lunch by using Image and load balancer handle the request portion. I can do this same work by elastic beanstack.
My question is, you said “Speed: Launching a new Amazon instance is a lot slower than launching a Docker container (Time=$)”. it makes me confused. I guess Docker container must need a EC2 machine first to lunch or where do it lunching? if so then Ec2 machine generally takes 2-3 minutes to lunch then how Docker saves time? Should i use Docker when i have only one web app in EC2 machine?
I am a newbee and very happy if u disappear my confusions about Docker.
Thank you