Over a million developers have joined DZone.

Deploy Docker Images to AWS Fargate — Run Containers Without Managing Infrastructure

DZone 's Guide to

Deploy Docker Images to AWS Fargate — Run Containers Without Managing Infrastructure

This tutorial shows how you can deploy Docker images of microservices to AWS Fargate without having to worry about container management.

· Microservices Zone ·
Free Resource

In the previous article, we looked at how to create a simple Spring Boot application and push it over to DockerHub. In this final article of this series, we will look into using the Docker image and deploying the application using AWS Fargate. AWS Fargate is a technology for Amazon ECS and EKS that allows you to run containers without having to manage servers or clusters. Fargate is an abstraction, so instead of you managing your instances and clusters, it will accomplish this for you.

Picking up from where we left, we have our image at DockerHub. We could easily have this pushed to AWS ECR as well. On AWS Fargate, we have the option to choose an existing configuration or create a custom one. Since we are working with a Spring Boot application, we will choose "Custom."

Default Container Definitions

Click on "configure" to add the Container Definition.

Container name: employeeapp

Image: coolindguy/employeeapp

*By default, the field accepts images from Document Hub. If you are using ECR, you have to provide the complete ECR URL.

  1. Memory limits: We can leave it at the soft limit of 128 MiB for our sample deployment.
  2. Port mappings: The service is running on port 8080, so we can map it to the same.

Task Definition: A task definition describes one or more containers through attributes. We leave everything as default for our purposes.

Create new
0.5GB (512)
0.25 vCPU (256)

Defining the Service and provisioning an ALB:

(This can be changed to a desired count of simultaneous task definitions in a cluster).

Automatically create new


Define the cluster for the application:

Automatically create new
Automatically create new

This is the desired state of our deployment:

Image title

At this point, we can review our deployment state and click on the "create" button. I did not have much luck getting the desired state a few times, so be patient with that.

Image title

After you see all 10 tasks completed, you can see the service details by clicking "View Service."

You can navigate to "Target Group Name" -> "Load Balancer" to get the DNS Name of the Load Balancer URL, which should give load balancer access to your containerized application running on AWS Fargate.

The same application can be deployed via ECS as well, but Fargate abstracts a lot of the complexity and you can focus on your application and not have to worry about the nitty-gritty of container management.

aws ,docker ,microservices ,deployment ,dockerhub ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}