Categories
Technology

Docker and Amazon Web Services Collaboration is AWSome

Docker Compose and Docker Desktop features now available for developers to use with Amazon ECS (Elastic Container Service) and Amazon Fargate.

You may have heard of containers before reading this post. And if you have, there’s a good chance that you’ve already heard of Docker. But in case you are new, here are a few cool features of using Docker:

  • Docker let’s you package your application code and dependencies into a Docker image, so that it can run your applications using Docker containers that are: portable – they can be taken and run anywhere, lightweight – Docker Containers share the machine’s operating system kernel, meaning they do not require an operating system per application. This reduces resources being consumed as well as server and licensing costs. And lastly, Docker Containers are secure – Docker Containers provide the most secure isolated environments for your application(s).
  • You can run your Docker Containers locally using Docker Engine or deploy them to Amazon ECR (Elastic Container Repository), and run serverlessly in your Amazon cloud by leveraging Amazon Fargate.

Here is a diagram of how Docker utilizes your computer’s resources to run your applications in isolated environments via Docker Containers, as long as you are running Docker Engine –

Photo cred: Docker.com

Now you may have also heard of virtual machines.

Why not run your applications in a virtual machine? Often micro-services that are run in virtual machines do not use all of the resources provisioned for the application(s), such as CPU, networking, RAM, processing and more. The most common problem being that there is unused space with virtual machines, and docker packages your code and dependencies with just the right tools to do the job correctly – which is running your application(s), and running them efficiently!

Now Docker Compose is a really cool tool for running multiple Docker Containers at once. You can use commands like: docker compose up in a terminal or using PowerShell (which I personally prefer) which will spin up (aka: run your applications locally) all of your applications in isolated Docker Containers at once. You can also shut down those same Docker Containers with the command: docker compose down. But do note that the images used to spin up your Docker Containers will still live locally on your machine.

In order to manage my images, containers, volumes etc., I use Portainer. I’m a huge fan of having a GUI (graphical user interface) for managing my containers, and Portainer has been my favorite tool to use with Docker and Docker Compose for a long time now. I highly recommend checking it out and installing it locally. Here’s what the GUI looks like –

Photo cred: LINUX UPRISING

Now the cool thing about Dockerizing your application(s), is that once your image has been create, you can then deploy your image to an Amazon ECR repository. I personally do this within my GitLab repositories using the AWS CLI. And I’ve written two previous articles on using both of those technologies, so check them out too! After you’ve successfully deployed those images to your AWS ECR repository, you can run your applications within Containers with your latest image in ECR inside an ECS Cluster on Amazon Fargate (if you want to run them serverlessly). Here’s a great article on doing so! Once you create your ECS Cluster you will need to define Task Definitions that explain which application(s) to run and how to run it/them.

For more information about Amazon Web Services partnership with Docker, check it out here!

Resources mentioned in this article:

Dale Yarborough

By Dale Yarborough

I am a Software Engineer at General Motors and Appalachian State University Alum. Previously: Whole Foods Market IT, Charles Schwab