Introduction to Docker & Amazon ECS — (Part 2)

Introduction to Docker & Amazon ECS — (Part 2)

Demo: Run A Docker Image In A production Environment Using Amazon ECS Go to Amazon’s login page and sign in if you already have an account. If you don’t, then go ahead and create a free account. Type in “ECS” and click on that service. You’ll see a Get started button if you haven’t created a cluster before. Go ahead by clicking on Get Started.

docker2.png Running a docker image on AWS ECS has 4 main steps, Container definition, Task definition, Service, Cluster.

image.png

Configure Container Definition: Select an image for your container. You have 4 options — A sample application image, Nginx image, tomcat-webserver, and a custom image.

image.png

For this demo, I’ve chosen the sample-app.

image.png Click on edit on the top right corner if you wish to change the configuration.

image.png You can edit the container name, the image to use, Memory limits, Port mappings, Healthcheck configurations, Environment configurations, Container timeout configurations, Network settings, Storage and Logging configurations, Resource limits, and Docker Labels. For this demo, I’ve used all the default configurations. Configure Task Definition: It consists of Task definition name, Network mode, Task execution role, capabilities, task memory, and Task CPU.

image.png You can click on Edit on the top right corner and configure according to your needs. For this demo, I’m using all the default configurations. Once you’re done, click on Next on the bottom right corner.

image.png Configure Service: You can go ahead and change the Service name, Number of desired tasks, Security Group and Select the Load balancer type. For this demo, I haven’t used a load balancer. Click on Next.

image.png Configure Cluster: Configure your cluster by adding a Cluster name and click on Next. Review: Once you’ve configured everything, you should see something like this.

Review everything and click on Create on the bottom right corner.

image.png All the services will now get created. This might take about 10 mins.

image.png Once everything has the completed status, click on View Services

image.png

You’ll see something like this. It’s going to show you your cluster details, task definition and an option to delete and update it.

image.png You can check further details like the VPC, Subnets, Tasks, Events, Autoscaling, Deployments, Metrics, Tags and Logs.

image.png

Now go ahead and click on task to check out the deployed container.

image.png Click on the task name as shown below.

image.png Click on ENI Id under the Network section.

image.png

You’ll be taken to the Network Interface page which would look like this:

image.png

Scroll down and you’ll see your IPV4 Public IP. Copy it.

image.png

Paste it on any browser like a URL. You’ll see the docker container output there. You’ll see your sample-app.

image.png

This was just a sample-app. You can run any kind of application or any kind of Docker image in just a few steps. This brings us to the end of this Amazon ECS article. You can integrate this service with various DevOps tools and can make the building process easier. I hope this blog was helpful.