9. It’s a shell-script?
$ cat SomeApp/Dockerfile
FROM ubuntu:13.10
RUN apt-get update; apt-get install apache
RUN sed ’s/something/else/‘ /etc/apache/httpd.conf
ADD shell-script.sh
RUN shell-script.sh
RUN [‘/usr/bin/apachectl’, ‘start’]
10. I ♥ #!/bin/bash
. oo # https://raw.githubusercontent.com/
# ewindisch/bashoo/master/lib/oo
# Classes are created implicitly through functions
function MsgWriter::new {
self=$1; shift
msg=$1; shift
instance_var $self msg $msg
}
function MsgWriter::write {
self=$1; shift
echo $($self.msg)
}
new terminal is MsgWriter “Hello World”
terminal.write
37. Containers are like
ephemeral VMs*
* Docker containers don’t HAVE to be ephemeral,
but it’s TheRightThing
Docker
Image
Linux
Chef
Runs
Image'
Linux
Chef
Chef
Runs
Configures
Container
Accesses
COW
TM
38. Bakery Chef
$ cat Dockerfile
FROM fedora
RUN yum update;
yum -y install chef"
ADD http://x/receipes.tar.gz /opt/chef"
ADD solo.rb /etc/chef/solo.rb"
RUN chef-solo -c /etc/chef/solo.rb
40. Expanded view:
Burning configuration into
images.
Docker Image tagInitiates
Image'
Linux
Chef
Chef
Build
Image
Linux
Chef
Creates
Creates
Runs Creates
References
1
2
43. Anatomy of a Docker
+Chef build & run
Docker ContainerInitiates Creates
Image
Linux
Chef
Chef
Runs
Configures
Chef
Runs
Configures
Build Creates
Stage 1 Stage 2
44. For All The Things!
$ cat Dockerfile
FROM fedora
RUN yum update;
yum -y install chef
ADD http://x/receipes.tar.gz /opt/chef"
ADD solo-stage1.rb /etc/chef/solo-stage1.rb"
ADD solo-stage2.rb /etc/chef/solo-stage2.rb"
RUN chef-solo -c /etc/chef/solo-stage1.rb"
CMD chef-solo -c /etc/chef/solo-stage2.rb; "
apachectl start
45. Does it converge?
$ docker build —rm .
$ echo $? # pass or fail
(This is great use of Docker as an
alternative to VMs for testing Chef recipes
targeting non-Docker production systems)