A New Sort-Of Virtualization Framework That Will Leave You Confused, Yet Excited For The Future Of Virtualization Technologies, If That's The Sort Of Thing You Usually Get Confused and/or Excited By
What is virtualization?
kvm, xen, virtualbox, etc
VMs are (usually)
Machine based
Hardware abstracted
Memory bound
(sometimes) Bound to hardware features
VMs are GREAT when you
Need multiuser environments
Need to run different architecture from your host
Need to do many things at once
Live in a wonderland where there is only dev
...and possibly testing
Have gobs and gobs and gobs and gobs and gobs of RAM and/or disk space
Hey, remember Java?
What are Linux Containers?
Containers are...
64bit Linux feature since ~v2.6 / 2009
OS-level virtualization
share kernel and other deps with host machine
Process isolation
So they are way more lightweight than traditional VMs, at a cost of abstraction
jbfink@soapy:~/work/dockerpreso$ git log
commit d3e33df5e15d0b24d5691de2c13f32d77a7f3ba8
Author: jbfink
Date: Wed Aug 14 11:00:46 2013 -0400
Then Docker is sort of like...
commit 82292af05a4aebff056a5117d197be0ff72f35a2
Author: jbfink
Date: Wed Aug 14 10:43:31 2013 -0400
More slides equals more fun.
commit 2aeae8de7ed3ac0c2ef19463183ee26ca7a4c97c
Author: jbfink
Date: Wed Aug 14 10:29:01 2013 -0400
Java FAIL FAIL FAIL
commit eabd742987a34aa44ac2dce01ac72bbb4e834675
Author: jbfink
Date: Wed Aug 14 10:22:11 2013 -0400
More changes equals more fun.
Docker is built on
Go
Linux >3.8
AUFS
dotCloud sez:
“Docker enables any application and its dependencies to be packaged up as a lightweight, portable, self-sufficient container. Containers have standard operations, thus enabling automation. And, they are designed to run on virtually any Linux server. The same container that that a developer builds and tests on a laptop will run at scale, in production, on VMs, bare-metal servers, OpenStack clusters, public instances, or combinations of the above.”
Docker containers are...
Small (thanks to AUFS)
Fast to set up, fast to tear down
repeatable
native to 64bit Linux but can run inside a Vagrant
So a Docker container can...
run any Linux distro
be built any way you like (Chef, Puppet, apt-get, yum)
and once built, will run exactly like you built it on any host you move the container to
This potentially means an END to every neckbeard holy war ever.
An example Dockerfile
FROM ubuntu:latest
MAINTAINER John Fink
RUN apt-get update
RUN apt-get -y upgrade
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql
RUN easy_install supervisor
ADD ./start.sh /start.sh
ADD ./foreground.sh /etc/apache2/foreground.sh
ADD ./supervisord.conf /etc/supervisord.conf
RUN rm -rf /var/www/
ADD http://wordpress.org/latest.tar.gz /wordpress.tar.gz
RUN tar xvzf /wordpress.tar.gz
RUN mv /wordpress /var/www/
RUN chown -R www-data:www-data /var/www/
RUN chmod 755 /start.sh
RUN chmod 755 /etc/apache2/foreground.sh
EXPOSE 80
CMD ["/bin/bash", "/start.sh"]
And a startup script
#!/bin/bash
if [ ! -f /var/www/wp-config.php ]; then
#mysql has to be started this way as it doesn't work to call from /etc/init.d
/usr/bin/mysqld_safe &
sleep 10s
# Here we generate random passwords (thank you pwgen!). The first two are for mysql users, the last batch for random keys in wp-config.php
WORDPRESS_DB="wordpress"
MYSQL_PASSWORD=`pwgen -c -n -1 12`
WORDPRESS_PASSWORD=`pwgen -c -n -1 12`
#This is so the passwords show up in logs.
echo mysql root password: $MYSQL_PASSWORD
echo wordpress password: $WORDPRESS_PASSWORD
echo $MYSQL_PASSWORD > /mysql-root-pw.txt
echo $WORDPRESS_PASSWORD > /wordpress-db-pw.txt
#there used to be a huge ugly line of sed and cat and pipe and stuff below,
#but thanks to @djfiander's thing at https://gist.github.com/djfiander/6141138
#there isn't now.
sed -e "s/database_name_here/$WORDPRESS_DB/
s/username_here/$WORDPRESS_DB/
s/password_here/$WORDPRESS_PASSWORD/
/'AUTH_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
/'SECURE_AUTH_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
/'LOGGED_IN_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
/'NONCE_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
/'AUTH_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/
/'SECURE_AUTH_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/
/'LOGGED_IN_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/
/'NONCE_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/" /var/www/wp-config-sample.php > /var/www/wp-config.php
chown www-data:www-data /var/www/wp-config.php
mysqladmin -u root password $MYSQL_PASSWORD
mysql -uroot -p$MYSQL_PASSWORD -e "CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY '$WORDPRESS_PASSWORD'; FLUSH PRIVILEGES;"
killall mysqld
sleep 10s
fi
supervisord -n