2014 Amazon.com, Inc. and its affiliates. All rights reserved.
May not be copied, modified, or distributed in whole or in part
without the express consent of Amazon.com, Inc. Running Docker on
AWS Jonathan Weiss @jweiss Amazon Web Services
Docker on AWS Do it yourself on EC2 Automate with AWS OpsWorks
AWS Beanstalk simplecontrol
Integrated application management service on EC2 powered by
Chef
Chef Setup Chef Client/Zero & OpsWorks Backend Chef Client
& Chef Server
Chef Setup in OpsWorks Supported Chef versions: 0.9, 11.4 or
11.10 Built-in convenience cookbooks / bring your own Chef run is
triggered by life cycle event firing Event comes with stack state
JSON
Why run Docker on OpsWorks? Full control of Docker version
& install Full control of mapping container to instance
Automation of AWS resources Resource discovery, e.g. other
containers
AWS OpsWorks
Stacks & Layers
Modeling in OpsWorks
Layers Group of instances with common behavior & settings
Chef recipes / run_list Settings / attributes Similar to a Chef
role
Built-in Layers Open Source at
http://github.com/aws/opsworks-cookbooks Rails MySQL PHP HAProxy
Node.js Memcached Java Ganglia
Custom Layers Define your own layers and their Chef run_list
Erlang app server Cassandra DB cluster C daemon Custom PHP install
Docker!
Custom Layers
Custom Layers
Custom Layers
Event Life Cycle
Events Events are triggered when your stack changes: Chef
run_list per event per layer Give you fine-grained control
Life Cycle Events 1 9 setup configure deploy undeploy
shutdown
Instance Life Cycle new
Instance Life Cycle new
Instance Life Cycle new online setup configure
Instance Life Cycle new online setup configure deploy
Instance Life Cycle new/stopped online setup configure
terminating shutting down deploy configure
Setup Event Sent when instance boots Includes deploy event Use
for initial installation of software & services Install
Docker
Configure Event Sent to all instances when any instance enters
or leaves online state Use for making sure the configuration is
up-to-date Update etcd config
Deploy Event Sent when you deploy via UI/API also part of each
setup Use for custom deployment Deploy Dockerfiles / images
Undeploy Event Sent via UI/API when apps are deleted Use to
remove apps from running instances Stop containers
Shutdown Event Sent when an instance is shut down ~45s to
execute Use for clean shutdown
Stack State JSON Each event gets JSON / attributes that define
the current stack state: node[:opsworks] search(:node,
"role:db-master") node[:opsworks][:layers] search(:node, "*")
node[:opsworks][:instance] node[:opsworks][:stack]
Creating a Docker Layer
Ingredients chef-docker cookbook from
https://github.com/bflad/chef-docker OpsWorks custom layer
Docker Layer Create a custom layer: Name: Docker Shortname:
docker
Setup Install Docker recipe[docker::default] Installs Docker
from source or package Handles dependencies like lxc, aufs or
cgroups Docker service and /etc/init/docker.conf
Deploy Manage Containers docker_image 'shipyard/shipyard' do
action :pull notifies :redeploy,'docker_container[shipyard]',
:immediately end docker_container 'shipyard' do action :run
end
Configure Update etcd if db_server = search(:node,
"role:db-master").first execute "Publish database IP" do command
"etcdctl set /db-ip #{db_server[:private_ip]}" end end
Undeploy docker_container 'shipyard' do signal 'QUIT' action
:kill end
Next Steps Have one custom layer per Docker app Configure
auto-scaling, ELBs, etc
Recap
AWS OpsWorks Life cycle automation framework Highly
customizable in the end everything is a Chef run Takes care of AWS
integration
Docker on OpsWorks Automate install & configuration of
Docker Fleet management Dynamic configuration
More information about AWS OpsWorks Follow us on twitter
@AWSOpsWorks Find us on YouTube Docs:
http://aws.amazon.com/documentation/opsworks Blog:
http://blogs.aws.amazon.com/application-management