3 Easy Ways to Deploy your Docker Web App on AWS

Jillian Rowe
Dabble of DevOps
Published in
4 min readDec 13, 2019

Deploy your Python, Node.js or RShiny app on AWS

AWS is shiny

AWS is so, so shiny and awesome, but when I first got started I felt overwhelmed by the sheer amount of stuff. There is so much flexibility, and cli tools, and ways to do anything. Initially, all I wanted to be able to do the things I’d always been able to do, like spin up a server and deploy a docker web application.

Today I am going to share 3 relatively easy methods to deploy your Docker projects on AWS. None of these solutions requires you to have much more AWS specific knowledge than knowing how to login. Having a bit of knowledge of security groups and virtual private clouds (VPC) will be helpful, but never fear! You can deploy your apps!

AWS EC2 Instance

Using the AWS Elastic Compute Cloud (get it? 2 Cs!) is probably the most straightforward and comfortable way for someone, including someone who knows nothing about the AWS ecosystem, to get started, but this is most certainly not a shiny solution.

Elastic Compute Cloud

The AWS Solution when you don’t know AWS

  • An EC2 instance is a server, normally a linux server.
  • You can do all the things you would normally do with any server!
  • SSH on over to your instance, install packages, rsync some projects, and run docker-compose up.
  • Using an EC2 instance is a not only a great starting point, but also scalable. You could eventually learn all the prettiness and through integrate it into a Docker Swarm, or an Auto Scaling Group.
  • It’s not sexy. Not even a little bit. You are not going to wow anyone with your AWS prowess by essentially administrating a remote a server.
  • While you certainly can scale, it is not automatically done for you in the background. Initially, you will start out with a single server, which may be plenty!
  • I don’t know of a way to directly, from the EC2 console, assign an instance a pretty IP address. You need to do this through the AWS domain manager.

If you have a single docker-compose application that doesn’t need a bunch of instances behind it, and you’re not that comfortable with AWS, this is definitely the easiest solution because it is just like any remote server you have ever used. This is the perfect solution for small projects and demos, but not so great for production web applications or web applications that need to scale.

AWS Elastic Beanstalk

The very first place that my googling led me to was AWS Elastic Beanstalk. I only used it once because while there were things I loved about it, there were other aspects I wasn’t so crazy about!

  • Fairly easy to get started if you are using a simple docker-compose file.
  • It’s the only solution that out of the box allows you to set up a reasonable URL, instead of the usual long string of letters and numbers you normally get.
  • Like all AWS resources the docs are great!
  • You upload your stack as a zip file which allows you to include other files.
  • You have to convert your docker-compose.yml to an AWS Elastic Beanstalk configuration, which is a pain if your docker-compose is complex!
  • The AWS Elastic Beanstalk configuration uses the array format for the startup command instead of a string. I found doing that translation to be very tricky.

If you have a simple docker-compose stack, and you know how to translate your startup commands from a string to an array you’ll be able to get up and going very quickly!

To see an example of deploying a Flask Application on Elastic Beanstalk check out my blog post here.

Docker Swarm on AWS

Now, I know that Docker Swarm is getting pushed out by Kubernetes, and I am jumping on that bandwagon, but I still love Docker Swarm. It’s much simpler than Kubernetes, and it can scale out to multiple nodes for large projects. Docker Swarm for AWS is a fantastic balance between relatively simple and robust.

This one is my personal favorite solution for Deploying Docker Applications on AWS

  • Once you have your Docker Swarm Configuration setup this is a press button solution.
  • Set the number of manager and worker nodes directly through the GUI.
  • Deploy to an existing VPC or a new one.
  • Your logs exist in the AWS logging solution, CloudWatch.
  • This solution can act as a gateway drug to shinier solutions with CloudFormation.
  • If you need GPU nodes you will need to modify the Cloud Formation template, and at that point you may as well go with another solutions.
  • There is no Elastic Scaling in this solution. You spin up a number of manager and worker nodes, and they just live there. It doesn’t scale based on the number of requests.

If you have an existing application that was deployed with Docker Swarm then this is the most straightforward solution to get your application out there on AWS. If you need anything a bit fancier, such as GPU, or an elastic cluster as a requirement, then you definitely need a fancier solution. So far, this is my favorite solution for deploying web applications on AWS.

Example

If you want to see how I deploy a Celery Job Queue using Docker for AWS here’s a post.

Originally published at https://www.dabbleofdevops.com.

--

--

Jillian Rowe
Dabble of DevOps

Bioinformatics Infrastructure Consultant. Mom of 2 awesome girls. Web: https://www.dabbleofdevops.com Email : jillian@dabbleofdevops.com Twitter: jillianerowe