Introduction into Docker
Daniel Banck, @dbanck
Was ist Docker?
Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.
Demo #1
Begriffe
- Container
- Image
- Tag
- Engine
- Client
- Hub
Container
A container is a self contained execution environment that shares the kernel of the host system and which is (optionally) isolated from other containers in the system.
VM vs. Container
Image
A Docker image is a read-only template. For example, an image could contain an Ubuntu operating system with Apache and your web application installed. Images are used to create Docker containers.
Tagging Images
$ docker tag 5db5f8471261 ouruser/sinatra:devel
$ docker images ouruser/sinatra
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ouruser/sinatra latest 5db5f8471261 11 hours ago 446.7 MB
ouruser/sinatra devel 5db5f8471261 11 hours ago 446.7 MB
ouruser/sinatra v2 5db5f8471261 11 hours ago 446.7 MB
Engine
Client
Hub
Docker Hub is the central hub for Docker. It hosts public Docker images and provides services to help you build and manage your Docker environment.
Erstellung
manuell oder automatisiert?
Manuell
Tutorial: https://www.docker.com/tryit/
Automatisiert
Dockerfile
Dockerfile?
FROM debian:jessie
MAINTAINER Stuart P. Bentley <stuart@testtrack4.com>
# Add the RethinkDB repository and public key
RUN apt-key adv --keyserver pgp.mit.edu --recv-keys \
1614552E5765227AEC39EFCFA7E00EF33A8F2399
RUN echo "deb http://download.rethinkdb.com/apt jessie main" \
> /etc/apt/sources.list.d/rethinkdb.list
ENV RETHINKDB_PACKAGE_VERSION 2.0.2~0jessie
RUN apt-get update \
&& apt-get install -y rethinkdb=$RETHINKDB_PACKAGE_VERSION \
&& rm -rf /var/lib/apt/lists/*
VOLUME ["/data"]
WORKDIR /data
CMD ["rethinkdb", "--bind", "all"]
# process cluster webui
EXPOSE 28015 29015 8080
Demo #2
$ brew install docker
$ brew install docker-machine
# VirtualBox should already be installed
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL
$ docker-machine create --driver virtualbox dev
[...]
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
dev * virtualbox Running tcp://192.168.99.100:2376
$ docker-machine env dev | source
$ docker ps -a
$ docker run --rm -it ubuntu:14.04
Mehrere Container
Linking
# RethinkDB Cluster
docker run -p 8080 --name rethink1 rethinkdb:latest
docker run --link rethink1 --name rethink2 rethinkdb:latest
# Simple App using RethinkDB
docker run --link rethink1 --name my-app app
docker-compose
db:
image: postgres:9.3
redis:
image: redis:2.8.13
backend:
image: productmate/webapp:latest
working_dir: /home/user/app
command: /home/user/.rvm/bin/app_bundle exec rails s
environment:
- RAILS_ENV=development
volumes:
- ../webapp:/home/user/app
links:
- db
- redis
Data volumes
A data volume is a specially-designated directory within one or more containers that bypasses the Union File System. Data volumes provide several useful features for persistent or shared data
Data Volume Container
If you have some persistent data that you want to share between containers, or want to use from non-persistent containers, it's best to create a named Data Volume Container, and then to mount the data from it.
Production?
- Apache Mesos / Mesosphere
- Google Kubernetes
- Docker Swarm
- Shipyard
- Panamax
- CoreOS Fleet
- Rancher
Etc, etc, etc...
Fragen?
Ausblick
Introduction into Docker
By Daniel Banck
Introduction into Docker
- 2,083