Publishing a web API to EC2 on AWS
In the previous section, we build the Docker image packtcontactsapi
for our ASP.NET Core Web API project. In this section, we will run this Docker image on the AWS EC2 container service.
Docker images are prebuilt with all required runtimes, which reduces the efforts of the published application to set up the environment.
Create an AWS account and move to the EC2 Container Service
section. Follow the steps (they are quiet easy) and you will be presented with commands to push the Docker image to AWS EC2. The commands are shown in the following screenshot:

AWS push commands to Docker images
Note
For more in-depth explanation of the steps involved in running Docker images on AWS EC2, refer to https://aws.amazon.com/getting-started/tutorials/deploy-docker-containers/.
Create a Task Definition. Here, you will specify the Docker image to be used. The underlined text in the following screenshot indicates the push image that is used:

Creating the task definition in AWS...