Running and managing large scale multi-container applications in production usually requires different tools than what is used for development.
In this webinar, we will show you how to use the Amazon EC2 Container Service CLI with Docker Compose to define and run multi-container applications in a local development environment. We will also show how you can eliminate the need to install, operate, and scale your own cluster management infrastructure by using Amazon ECS. We will then demonstrate how to schedule your multi-container application as defined by Compose across a production Amazon ECS cluster. We will also walk through some best practice patterns used by customers for running their microservices platforms or batch jobs.
Learning Objectives:
Understand the basics of the Amazon ECS CLI
Run multi-container applications defined by Docker Compose using the Amazon ECS CLI
Learn how to run and manage production applications using Amazon ECS
Who Should Attend:
Developers, system administrators, Docker users, container users
7. Cluster Management Made Easy
No cluster software to install and manage
Manages cluster state
Manages containers
Control and monitoring
Scale from one to tens of thousands of containers
10. Designed for use with other AWS services
Elastic Load Balancing
Amazon Elastic Block Store
Amazon Virtual Private Cloud
AWS Identity and Access Management
AWS CloudTrail
13. Services evolve to microservices
MVC Application
Order UI User UI Shipping UI
Order
Service
User
Service
Shipping
Service
Data
Access
Host 1
Service A
Service B
Host 2
Service B
Service D
Host 3
Service A
Service C
Host 4
Service B
Service C
14. Containers are natural for services
Simple to model
Any app, any language
Image is the version
Test & deploy same artifact
Stateless servers decrease change risk
20. Task definitions
Processes that run together on
the same instance
Scale in tandem
May share common resources
such as files, or links
Often exposed through one
endpoint
23. Typical user workflow
Run Instances Amazon
EC2
Use custom AMI with
Docker support and
ECS Agent. Instances
will register with
default cluster.
24. Typical user workflow
Create Task Definition
Declare resource
requirements for
containers
Shared Data Volume
PHP App
Time of day
App
25. Typical user workflow
Create Service
Declare resource
requirements for
service
Shared Data Volume
PHP App
Time of day
App
Elastic
Load
Balancing
X 5
27. Typical user workflow
Scale Service
Drain Connections
Shared Data Volume
PHP App
Time of day
App
Elastic
Load
Balancing
X 2
28. Typical user workflow
Deploy new
version
Rolling
deployment,
health checks,
drain connections
Shared Data Volume
PHP App
Time of day
App
Elastic
Load
Balancing
X 2
29. ECS CLI
High-level commands to simplify creating, updating, and
monitoring clusters and tasks
Supports Docker Compose, a popular open-source tool for
defining and running multi-container applications
Binaries available for Mac OSX and Linux
Open source, download, comment
https://github.com/aws/amazon-ecs-cli
30. Create an ECS cluster
Creates all the resources required by your cluster in one command
$ ecs-cli up --keypair id_rsa --capability-iam --size 2 --instance-type t2.medium INFO[0000]
Created cluster cluster=ecs-cli-demo
INFO[0000] Waiting for your cluster resources to be created
INFO[0001] Cloudformation stack status stackStatus=CREATE_IN_PROGRESS
31. Docker Compose
Model multi-container services
Run on desktop and AWS
Store in source control
web:
image: amazon/amazon-ecs-
sample
ports:
- "80:80"
32. Run Compose Locally
Run Compose on the local dev environment
$ docker-compose up
Creating compose_web_1...
Attaching to compose_web_1
33. Deploy the Compose File to an ECS Cluster
Can run stand-alone tasks or create an ECS service
$ ecs-cli compose service up
INFO[0000] Using ECS task definition TaskDefinition=ecscompose-cli-
webinar:1
INFO[0000] Created an ECS Service serviceName=ecscompose-service-cli-
webinar taskDefinition=ecscompose-cli-webinar:1
INFO[0000] Updated ECS service successfully desiredCount=1 serviceName=ecscompose-
service-cli-webinar
INFO[0000] Describe ECS Service status desiredCount=1 runningCount=0
serviceName=ecscompose-service-cli-webinar
34. View the Running Containers
View what you created
$ ecs-cli service ps
Name State Ports TaskDefinition
46163c8a-fd75-481d-a670-1bda9f433493/web RUNNING 52.91.66.37:80->80/tcp ecscompose-cli-
webinar:1
35. Scale your service
Add more tasks to scale the service
$ ecs-cli compose service scale 2
INFO[0000] Updated ECS service successfully desiredCount=2 serviceName=ecscompose-
service-cli-webinar
INFO[0000] Describe ECS Service status desiredCount=2 runningCount=1
serviceName=ecscompose-service-cli-webinar
36. Update your service
Change docker-compose.yml to
include an nginx proxy and redeploy
$ ecs-cli compose service up
INFO[0000] Using ECS task definition TaskDefinition=ecscompose-cli-
webinar:2
INFO[0000] Updated the ECS service with a new task definition. Old containers will be stopped
automatically, and replaced with new ones desiredCount=2 serviceName=ecscompose-service-cli-
webinar taskDefinition=ecscompose-cli-webinar:2
INFO[0000] ECS Service has reached a stable state desiredCount=2 runningCount=2
serviceName=ecscompose-service-cli-webinar