A talk for BBLISA, 2014-10-08
Colin Walters, Platform Engineering, Red Hat, Inc.
Project Atomic is not a distribution. It is a pattern around a set of upstream projects that can be applied to a distribution.
Classic problem: I have two web apps I want to run on the same host.
Assemble a Docker image with apache, from CentOS RPMs
$ cat > Dockerfile << EOF
FROM centos
RUN yum -y upgrade && yum -y install httpd && yum clean all
EXPOSE 80
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
EOF
$ sudo docker build -t cgwalters/apache .
Run it
$ sudo docker run -d -P cgwalters/apache
$ sudo docker ps -a
$ curl http://127.0.0.1:${port}
Container thinks it's port 80
Create derived images
$ cat > Dockerfile << EOF
FROM cgwalters/apache
echo "<body>Container one</body>" > /var/www/html/index.html
EOF
Run them both
# sudo docker run -d cgwalters/httpd1
# sudo docker run -d cgwalters/httpd2
# sudo docker ps
$ curl http://127.0.0.1:${firstport}
$ curl http://127.0.0.1:${secondport}
$ sudo docker run -t -i centos bash
# ps auxwf
# ip link
# mount
# hostname
CLONE_NEWPID, CLONE_NEWNET, CLONE_...
TL;DR: You are running code as root, kernel is large attack surface.
The Docker union filesystem
Written to the container by default (do not do this in production)
Do use docker run --rm
# lvm lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
docker-data atomicos -wi-ao---- 11.54g
docker-meta atomicos -wi-ao---- 1.00g
root atomicos -wi-ao---- 3.13g
swap atomicos -wi-ao---- 128.00m
# docker info |grep Space
Data Space Used: 594.6 Mb
Data Space Total: 11820.0 Mb
Metadata Space Used: 0.5 Mb
Metadata Space Total: 1024.0 Mb
#
Server: rpm-ostree compose tree
Client: rpm-ostree upgrade
# atomic status
TIMESTAMP (UTC) ID OSNAME REFSPEC
* 2014-10-07 19:29:55 9e8fd0f4bd rhel-atomic-host brew:rhel-atomic-host/7/x86_64/standard
2014-09-29 22:03:42 80986d2569 rhel-atomic-host brew:rhel-atomic-host/7/x86_64/standard
# atomic upgrade
Receiving objects: 71% (25/35) 2.4 MB
^C
Copying /etc changes: 13 modified, 0 removed, 18 added
Transaction complete; bootconfig swap: yes deployment count change: 0)
Freed objects: 79.8 MB
Changed:
NetworkManager-1:0.9.9.1-26.git20140326.4dba720.l7_0.x86_64
NetworkManager-glib-1:0.9.9.1-26.git20140326.4dba720.l7_0.x86_64
cloud-init-0.7.5-1.l7_0.x86_64
dhclient-12:4.2.5-27.l7_0.1.x86_64
dhcp-common-12:4.2.5-27.l7_0.1.x86_64
dhcp-libs-12:4.2.5-27.l7_0.1.x86_64
docker-1.2.0-17.l7.x86_64
kernel-3.10.0-123.8.1.l7.x86_64
Removed:
PackageKit-glib-0.8.9-11.l7.x86_64
accountsservice-0.6.35-7.l7.x86_64
accountsservice-libs-0.6.35-7.l7.x86_64
make-1:3.82-21.l7.x86_64
Added:
bridge-utils-1.5-9.l7.x86_64
cadvisor-0.4.0-0.0.git5a6d06c0.l7.x86_64
etcd-0.4.6-3.l7.x86_64
irqbalance-2:1.0.6-5.l7.x86_64
kubernetes-0.2-0.9.gitf7a5ec3.l7.x86_64
# atomic status
TIMESTAMP (UTC) ID OSNAME REFSPEC
2014-10-08 12:23:35 ed78ff0b4d rhel-atomic-host brew:rhel-atomic-host/7/x86_64/standard
* 2014-09-29 22:03:42 80986d2569 rhel-atomic-host brew:rhel-atomic-host/7/x86_64/standard
# atomic rollback
Completely safe (and also atomic!) swap of bootloader entries.
For production, optimize storage like Atomic