10 Steps Deploying Docker Containers on AWS Elastic Beanstalk – Flux7

By admin
June 19, 2014

docker on AWS ELB

Amazon Web Services (AWS) Elastic Beanstalk (EB) is a service to deploy your code. This easy-to-use service works as a Platform as a Service (PaaS). It supports familiar web applications, such as PHP, Node.js, Ruby, Python, Java and .Net. You can simply choose your software stack and upload your code. AWS will take care of the provisioning of the environment, deploying the code, load balancing, auto scaling, and health monitoring. At the end of the process, it prints a url used to access the application.

Recently, AWS added support for Docker containers. Before Docker, EB limited your choices to available stacks in the drop-down list. This forced you to choose predefined versions offered by AWS. For example, by default, PHP on EB runs on Apache. If you want to replace Apache with Nginx+PHP-FPM, there is no way you can do that. Customization of Amazon Machine Images (AMI) used in EB is very limited.

But now Docker is enabling flexibility for users to deploy any software stack in EB.

You are no longer solely dependent on software versions supported by EB. You can run whatever you want or need to in a container, and deploy it to EB. You can run multiple Tomcat or MySQL servers, or even multiple Apache servers, in a single container. You can even run your own customized Java service in a container and deploy it to EB.

Sound interesting? Ready to evaluate Docker? Then let’s discuss how you can deploy a Docker container in EB using 10 easy steps.

There are three ways you can deploy docker containers in EB. We assume you already know about the Docker concepts. If you don’t know about Docker, you can get a quick study here.

Here are the three ways:

1. Create a Dockerfile and upload it to EB.

2. Create a Dockerrun.aws.json file to deploy an existing Docker image.

3. Create a zip file with Dockerfile, Dockerrun.aws.json, and any application file, then upload to EB.

Dockerrun.aws.json: This is specific to AWS EB. This describes how to deploy a container in EB. (Learn more here.)

In the following 10-step tutorial, we are describing how to deploy a pre-baked Docker container from a Docker repo to AWS EB.

1. Create S3 bucket.

2. Commit Docker image.

Create a Docker image using all the required packages installed, the deploy the code. If the database is outside of the container, then be sure you have deployed the updated code.

Commit the docker image to Docker repo.

3. Create Docker Authentication configuration file:

  • Login to Docker repo using Linux terminal.
$ docker login
  • It prompts you for the logins and email. Once you enter the credentials, Docker creates .dockerconfig file in the user’s home directory.
  • Upload the dockerconfig file to the S3 bucket. EB will read this file to get the access to Docker repo.

The config file will then look like this:


4. Create Dockerrun.aws.json

This file describes how to deploy a container in AWS EB. Please see the configuration file here:

Subscribe Here!

Posts by Topic

Show More