Introduction to AWS Containers
Containers are standardized software development units that let you package your application’s code, configurations, and it’s dependencies into a single object. Containers are derived from the principles of OS-level virtualization. It lets you run the application and its dependencies in resource-isolated processes, which ensures quick, reliable, and consistent deployments in any environment.
Types of Containers
Container management tools can be categorized into three types: registry, orchestration, and compute. Registry services help you to securely store and manage your container images. Orchestration manages when and where your containers run. And Compute engines power your containers. All the underlying infrastructures are taken care of by AWS. Containers make developments and deployments easy and efficient.
Amazon Elastic Container Registry (ECR)
It is a highly scalable, highly available, highly secure, and fully-managed Docker container registry. It helps the developers to store, manage, and deploy Docker container images efficiently. Amazon ECR is integrated with Amazon Elastic Container Service (ECS), which simplifies the deployment. Amazon ECR is payable only for the amount of data you store in your repositories and data transferred on the internet.
Example of Docker image creation of a simple web application and pushing it into Amazon ECR:
- Create a file, Dockerfile.
- Edit the Dockerfile.
- Build a Docker image.
- Verify the Docker image, by running it.
- Run the newly built image.
- Point your browser to http://locallhost.com/and the output will be:
- Stop the Docker container by typing Ctrl + c.
- Push your image to Amazon ECR. Create an Amazon ECR repository to store the image.
- Tag the ecr-example image with Uri value.
- Run the Docker login authentication command for your registry.
- Run the Docker login command.
- Push the image to Amazon ECR with the repository Uri
Amazon Elastic Container Service (ECS)
It is a fully-managed, highly scalable, and high-performance container management service. It supports Docker containers and lets users to efficiently run the application on a managed cluster of EC2 instances. The installations and operations of container orchestration are managed by AWS.
Example of deploying Docker containers on Amazon ECS:
- Amazon ECS – First Run Set-Up: It will let you create clusters and launch sample web applications. You will enter the Amazon ECS Console and launch the wizard. You can also use Amazon ECR to create an image repository and push the image to it.
Select the option and select Continue.
- Task Definition Creation: It is the blueprint of your application. Review the default values and select the Next Step.
- Service Configuration: The service launches and maintains copies of the task definition in your cluster.
- Service Name: AWS provides a sample web-based “Hello World” application sample-web-app by default.
- Desired Number of Tasks: Default value is 1, for AWS free tier.
- Elastic Load Balancing: You may use a load balancer with your service.
- Container Name: Host Port: select Simple-app:80 and default the remaining fields.
Select Service IAM Role if you already have from the drop-down or Amazon ECS will create an ECS service role by default.
4.5 (2,190 ratings)
Review your inputs and select the Next Step.
- Cluster Configuration
- Cluster Name: Default name is sample-cluster.
- EC2 Instance Type: Default type is t2.micro for AWS free tier.
- A Number of Instances: Default value is 1, for AWS free tier.
- Key Pair: You can continue by selecting one – Unable to SSH.
- Security Group: Anywhere by default. It allows access from the entire internet.
- Container Instance IAM Role: select one if you already have from the drop-down or
Amazon ECS will create one by default.
Select Review and Launch.
- Launch and View Resources
You can review your task definition, task configuration, and cluster configurations before launching.
Select Launch instance & run service.
After the launch is complete, select View service.
- Open the Sample Application: You can verify and run your sample application by pointing your browser to the load balancer DNS name.
Open the sample-web-app page and select your load balancer name.
Copy the ELB DNS name and paste it into a new browser and hit Enter on your keyboard.
You can view your sample application.
You can also clean up your resources anytime to avoid unnecessary charges.
Amazon Elastic Kubernetes Service (EKS)
It lets you easily manage, deploy, and scale containerized applications using Kubernetes on AWS. It runs Kubernetes service across multiple AWS zones to eliminate a single point of error. Amazon EKS is a certified Kubernetes integration, you can easily migrate application running on any standard Kubernetes environment to AWS EKS.
Amazon Elastic Compute Cloud (Amazon EC2)
It is a secure and resizable compute capacity in the cloud that runs containers on virtual machine infrastructures with full control over scaling and configuration. It gives you complete control of your computing resources. It reduces the time required to obtain and boot new server instances to just a few minutes. Amazon EC2 provides developers the tools for building failure resistant applications.
Example: Install a LAMP Web Server with the Amazon Linux AMI.
This example helps you install an Apache web server with PHP and MySQL support on your Amazon Linux instance (also called LAMP web-server).
- Connect to Linux instance.
- Update software packages, if any.
- Install the Apache web server, MySQL, and PHP software packages using the yum install command.
- Start the Apache webserver.
- Configure the Apache web-server to start at each system boot.
- Verify that httpd is on.
- Add a new inbound security rule with the following values:
- Type: HTTP
- Protocol: TCP
- Port Range: 80
- Source: Custom
- Test the webserver, by typing the DNS address in a web browser.
- Set necessary file permissions if necessary.
- Test your LAMP server.
- Secure the Database Server.
It is a serverless compute engine for Amazon ECS that allows you to run containers without managing servers. Amazon takes care of all under-lying server managements letting you focus on designing and building your applications
It has two modes:
Fargate Launch Type: Package your application in containers, specify the CPU and memory requirements, define networking and IAM policies and launch the application.
EC2 Launch Type: It allows you to have a server-level control over a facility that runs your container applications.
Benefits of AWS Containers
- Runs Anywhere: Containers package your code with the configuration files and dependencies it needs to run in any environment consistently.
- Improve Resource Utilization: Containers provide process isolation that lets you set CPU and memory utilization for better use of computes resources.
- Quick Scaling: Every container runs as a separate process that shares the resources of the underlying operating system. This lets containers to start and stop quickly.
How Does it work?
- Build a Container Image: Package your code and all its dependencies into a container.
- Automate Test and Deployment: Standardized unit of code, the container acts as a consistent building
- Run anywhere: Your container will run in any environment consistently.
- Rapid Scaling: Containers start and terminate quickly, so your application can scale up and down
Conclusion – AWS Containers
Amazon provides a broad range of services for storing, managing and running containers. Containers make developments and deployments easier for developers as all the underlying infrastructures including server management are taken care of by Amazon, letting developers focus on their development. Chose the right AWS service for your workload.
This is a guide to AWS Containers. Here we discuss the Introduction, Types of Containers which includes Registry, Orchestration and Compute along with the Benefits of AWS Containers. You may also look at the following articles to learn more–