Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Docker and AMI

In the context of AWS:

AMI is used to package software and can be deployed on EC2. Docker can also be used to package software and can also be deployed to EC2.

What's the difference between both and how do I choose between them?

like image 480
Schleir Avatar asked Jan 16 '17 23:01

Schleir


People also ask

Is AMI same as Docker?

An AMI is an image. This is a whole machine that you can start new instances from. A docker container is more lightweight and portable. A docker container should be transportable between providers while an AMI is not (easily).

What is difference between Docker and AWS?

A Docker container is an instantiated (running) Docker image. AWS provides Amazon Elastic Container Registry (ECR), an image registry for storing and quickly retrieving Docker images.

What is the difference between an AMI and an instance?

An Amazon Machine Image (AMI) is a template that contains a software configuration (for example, an operating system, an application server, and applications). From an AMI, you launch an instance, which is a copy of the AMI running as a virtual server in the cloud.

Is EC2 a Docker container?

Summary. You can run Docker containers on AWS EC2 by installing Docker. You need to install Docker CLI, AWS account setup and you need to create an IAM user as an administrator. You can pull Docker images from Docker Hub and when you run those containers you should expose on port 80.


2 Answers

An AMI is an image. This is a whole machine that you can start new instances from. A docker container is more lightweight and portable. A docker container should be transportable between providers while an AMI is not (easily).

AMI's are VM images basically. Docker containers are packaged mini-images that run on some VM in an isolated environment.

like image 110
Jerry Vines Avatar answered Sep 30 '22 19:09

Jerry Vines


Eventhough this doesn't answer the question directly, but gives some background on how they are used.

One approach is you launch EC2 instances with Amazon AMI's (or can be any AMI) then run docker containers (with all dependencies) on top of it. With this approach, the docker image gets bloated over time and there is a container drift over time. Also time taken for the application to be up and running is more as the Ec2 has to be booted and docker has to bring up your app server.

Another approach is "Immutable Ec2 instances". With this approach, you use Amazon AMI as base and install all the dependencies ( use shell scripts or Ansible) and bake them in the AMI. We use Hashicorp Packer which is an amazing tool. Here the time taken for the application to be up and running is greatly reduced as all the dependencies ( java8 , tomcat, war file etc) are already installed in the AMI.

For production use case, use Packer to create AMI and use Terraform to launch cloud resources to use this AMI. Tie all this together in Jenkins pipeline.

like image 21
VimalKumar Avatar answered Sep 30 '22 18:09

VimalKumar