docker harbor tour
4th DUGS Meetup 12.9.13
Stefan Reinhard, sr@feinheit.ch
Everybody raise your hands...
-
Who uses vagrant for devenvs?
-
Who is deploying to any PaaS?
-
Who has heard of docker before?
What is Docker?
Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application.
The same container that a developer builds and tests on a laptop can run at scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more.
Ok, so what's a container?
- OS-level virtualization (not simulating hw)
- Faster and smaller than VMS
- chroot on stereoids
- Many flavours around (OpenVZ, VServer, LXC)
- Docker currently supports LXC exclusively
Let's try this...
$ docker run -i -t ubuntu /bin/bash
What's the deal?
Use the same container for:
- Development
- Testing
- Production
Development
- Pull an image and go
- High dev/prod parity
- Isolated everyting
- Low resource consumption
Testing
- Isolated test environment
- System tests incl. backing services
- Run tests parallel if you want
Deployment
We'll get there later... ;-)
Docker Core Concepts:
-
Container: State of a VM
-
Images: Snaphots of containers
-
Index/Registry: Repository of containers
-
Dockerfile: Buildscript for images
-
Layers: Stack of filesystems
Building Images manually
# Start a new container
$ docker run -i -t ubuntu:12.10 bash
# Do stuff
[c123]# apt-get update
[c123]# apt-get install memcached
[c123]# exit
# Save container as an image
$ docker commit -m "memcache" c123 username/image
Build images with Dockerfiles
Dockerfile:
FROM ubuntu
RUN apt-get update
RUN apt-get install -y memcached
In Terminal:
$ docker build -t sr/memcached .
$ docker run sr/memcached memcached -u root
dock your first app
-
Just start a container and hack away
(Don't tinker with Dockerfiles too long)
- Commit your container when it's ready
- Remember: containers are persistent
-
Start with a minimal running version
(Don't install nginx, db and such)
- Mount local volumes:
$ docker run -v /host:/container ...
Common gotchas
- Service discovery:
- No reliable connection to host or other containers
- Solution 1: dns-server & env vars
- Solution 2: etcd distributed key value store
- Solution 3: maestro docker orchestration
- ...
- Process monitoring:
- Only one process running in container when started
- Upstart doesn't work with custom scripts for me
- Solution 1: Create bash script to start everything
- Solution 2: Use supervisor / foreman / honcho etc.
The last demo, i promise
$ docker run guetux/feincms
distribute images:
docker registry
$ docker login
$ docker push guetux/feincms
Registry can be self hosted:
Dokku
Docker powered mini-Heroku.
The smallest PaaS implementation you've ever seen.
Docker has a lot of momentum
Use containers to ship code
like git for devops
Not production ready (yet)
Awesome for demo apps now