What is Docker and why should you care? A Docker container is like a
lightweight Virtual Machine. It gives you the benefits of a virtual machine,
isolation of your application, without the drawbacks, having to ship an entire
operating system with your application, slow startup time, and difficult
interaction with the host.
In this presentation you will learn why Docker and containerization is the
future of DevOps and how to use it efficiently. You will learn how to build,
run, and link containers, and what volumes are and what they are used for.
You will also learn about some of the many orchestration solutions that exists
for managing a cluster of containers, both locally and in the cloud.
4. • Consultant Company
• Malmö, København, Halmstad, Helsingborg,
Stockholm, San Fransisco
• A lot of competence activities
• Competence weekends, competence days, Øredev
• We are hiring!
21. 100x Faster Enables
• Throwaway dev environments
• Databases, Filesystems, Tools
• Throwaway test environments
• Filesystems, Databases
• Throwaway prod environments
• Upgrade the server by plopping in a new container
29. Images
$ docker images # shows all images.
$ docker import # creates an image from a tarball.
$ docker build # creates image from Dockerfile.
$ docker commit # creates image from a container.
$ docker rmi # removes an image.
$ docker history # list changes of an image.
34. Dockerfiles
FROM debian:jessie
RUN apt-get update
RUN apt-get install postgresql
RUN curl https://iojs.org/dist/iojs-v1.2.0.tgz -o iojs.tgz
RUN tar xzf iojs.tgz
RUN cp -r iojs-v1.2.0-linux-x64/* /usr/local
$ docker build -tag postgres-iojs .
40. Containers
$ docker create # creates a container but does not start it.
$ docker run # creates and starts a container.
$ docker stop # stops it.
$ docker start # will start it again.
$ docker restart # restarts a container.
$ docker rm # deletes a container.
$ docker kill # sends a SIGKILL to a container.
$ docker attach # will connect to a running container.
$ docker wait # blocks until container stops.
$ docker exec # executes a command in a running container.
41. docker run
$ docker run -it --rm ubuntu
--interactive (-i)
--tty (-t)
--rm
ubuntu
81. docker-compose up
1 $ docker-compose up
2 Pulling image orchardup/redis...
3 Building web...
4 Starting figtest_redis_1...
5 Starting figtest_web_1...
6 redis_1 | [8] 02 Jan 18:43:35.576 # Server
7 started, Redis version 2.8.3
8 web_1 | * Running on http://0.0.0.0:5000/
82. docker-compose up -d
1 $ docker-compose up -d
2 Starting figtest_redis_1...
3 Starting figtest_web_1...
4 $ docker-compose ps
5 Name Command State Ports
6 ------------------------------------------------------------
7 figtest_redis_1 /usr/local/bin/run Up
8 figtest_web_1 /bin/sh -c python app.py Up 5000->5000
83. Other stuff
1 # Get env variables for web container
2 $ docker-compose run web env
3 # Scale to multiple containers
4 $ docker-compose scale web=3 redis=2
5 # Get logs for all containers
6 $ docker-compose logs
86. Core OS Linux
• Minimal 114MB RAM on boot
• No package manager, Docker
• Dual-partition scheme
• Read-only boot partitions
• Managed Linux
87. systemd
• Performance, boots extremely fast
• Logging journal has great features
• JSON export
• Forward secure sealing
• Indexing for fast querying
• Socket Activation
88. etcd
• A distributed, consistent key value
store for shared configuration and
service discovery
89. Etcd
1 # Set a value that expires after 60s
2 # Also creates dir /foo is it does not exist
3 $ etcdctl set /foo/bar "Hello world" --ttl 60
4 Hello world
5
6 # Get a value
7 $ etcdctl get /foo/bar
8 Hello world
9
25 # List a directory recursively
26 $ etcdctl ls --recursive /
27 /coreos.com
28 ...
33 # Watch a key for changes
34 $ etcdctl watch /foo/bar
35 Hello world
90. fleet
• Cluster manager
• Extension of systemd
• Uses etcd for configuration
• On every Core OS machine
91. fleet
DEMO
DEMO
• Start a single container
• Start a container on every host
• Start a dependent container