Slides from Ansible Oxford meetup on 29th July 2015: Cows and Containers. How does Ansible play with Docker? How can we use Ansible to build, ship and run Docker containers?
6. New problems:
How do I build my Dockerimages?
How do I run my containers?
How do I ship them?
7. First stab
Write a Dockerfile (basically a shell
script written as a children's book)
RUN apt-get update
RUN apt-get –y install awesome
COPY myfile /tmp/
12. $ cat myapp/Dockerfile
FROM ubuntu:14.04
MAINTAINER jonatanblue version: 0.3
# Install Ansible
RUN apt-get -y update && apt-get install -y software-properties-common
RUN echo | apt-add-repository ppa:ansible/ansible
RUN apt-get -y update && apt-get -y install ansible
# Copy over playbook
COPY moo/container.yml /tmp/
# Run playbook
RUN ansible-playbook /tmp/container.yml
13. - name: build image
docker_image:
name: “jonatanblue/myapp:0.3”
OR ( if because above is still a bit unstable)
$ cd myapp
$ docker build --tag=“jonatanblue/myapp:0.3” .
14. Run with Ansible
* “Static” workloads – docker module
* Distributed applications
– … it’s complicated
17. Active orchestration
1. Resources (busy, free, time to
release, control)
2. Running containers
3. Application health
• Act on this information
• Automatic control problem != trivial
18. Example on AWS
Server1: 2 of 4 cores & 6 of 8GB RAM free
Server2: 4 of 4 cores & 8 of 8GB RAM free
Requirements
Container1: 1core, 1GB
Other stats:
No containers started in last hour, historical data suggests
off-peak period
! Launch container on server1 and terminate server2
19. Mesos - a single pool of resources
http://mesos.apache.org/
Kubernetes - orchestration system
http://kubernetes.io/
20. 2 observations
• Applications to manage Docker
(deployed by Ansible)
• Docker in docker in docker… Registry
great example (built & started by
Ansible)