Тарас Кирилюк — docker basics. how-to for drupal developers

Post on 15-Apr-2017

126 Views

Category:

Internet

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Docker basics.How-to For Drupal devs

Hi @here!I am Taras KyryliukI am here because I have been

using Docker for almost a Year and

have something to say about it

2

Disclaimer: I am a Drupal developer and automation maniac

Overview

▹ Software isolation

▹ Introducing Docker

▹ Docker in Drupal development

3

1.Software isolation

4

Why we need Software Isolation?

Starting from the assumption that software will always have bugs, we need a way to isolate and neutralize the effects of the bugs…

© internet

5

6 Virtualization

Operating system-level

Containers

OpenVZ, Solaris Zones, lxc, libcontainer

Hardware-level

Virtual machines

KVM, Xen, VMware, VirtualBox, xhyve

Operating system-level virtualization - Containerisation

▹ Limited overhead▹ Do not require a hypervisor layer▹ Allow a greater density of containers to run on a host▹ Can be complex, hard to set up, and difficult to

manage and automate▹ Can run the same or a similar guest operating system

as the host machine

7

Containerisation

8

Hardware virtualization

▹ Large overhead because of hypervisor layer▹ Easy to run and manage▹ Can run any operating system

9

Hardware virtualization

10

11

2. Introducing Docker

Docker is an open-source engine that automates the deployment of applications

into containers.

12

Docker containers wrap a piece of software in a complete filesystem that

contains everything needed to run: code, runtime, system tools, system

libraries – anything that can be installed on a server. This guarantees that the

software will always run the same, regardless of its environment.

https://www.docker.com/what-docker

13

▹ The Docker client and server

▹ Docker Images

▹ Registries

▹ Docker Containers

14

Docker components

15

Docker architecture

“Images are the building blocks of the Docker world.”https://www.dockerbook.com

Ways to create images:▹ Building an image from a Dockerfile

▹ Updating and committing an image

Docker images16

17

Building an image from a Dockerfile

18

Building an image from a Dockerfile

$ docker build -t tutorial/nginx .

Updating and committing an image

Run container:$ docker run -t -i training/sinatra /bin/bashInstall what you need:$ root@0b2616b0e5a8:/# apt-get install -y ruby2.0-dev$ root@0b2616b0e5a8:/# gem2.0 install jsonCommit changes:$ docker commit -m "Added json gem" -a "Kate Smith" 0b2616b0e5a8 ouruser/sinatra:v2

https://docs.docker.com/engine/tutorials/dockerimages/

19

▹ Docker Hub (public and private repositories)

▹ Own private registry

▹ Hosted private registry

Docker registries20

Run first container21

Container ports magic22

Host OS

8080

Container with Nginx

80

3. Docker in Drupal developmentWhat problems we can solve using it.

23

Docker use cases

▹ Use container as a Service

▹ Use container as a tool

▹ Run one host Drupal project with Docker Compose

▹ Run own cloud with Docker Swarm

24

Container as a Service(MySQL as an example)

Run:$ docker run -d --name=example-mysql --env="MYSQL_ROOT_PASSWORD=mypassword" mysql

Get IP:$ docker inspect example-mysql

Install Mysql Client:$ apt-get install mysql-client

Profit:$ mysql -uroot -pmypassword -h 172.17.0.20 -P 3306mysql>

25

http://severalnines.com/blog/mysql-docker-containers-understanding-basics

Container as a Service(MySQL as an example)26

http://severalnines.com/blog/mysql-docker-containers-understanding-basics

Use container as a tool(PHPUnit as an example)27

https://hub.docker.com/r/phpunit/phpunit/

cd to folder with tests and Run:

$ docker run -v $(pwd):/app --rm phpunit/phpunit run

Profit!▹ No need to install▹ Choose any version▹ Can use different versions for different projects

DEV-STAGE-PROD env with Docker Compose

▹ Compose is a tool for defining and running

multi-container Docker applications.

▹ With Docker Compose, we define a set of

containers to boot up, and their runtime

properties, all defined in a YAML file.

28

Exampledocker-compose.yml

29

DEV-STAGE-PROD env with Docker ComposeYou should have set of Compose-files for different environments.

▹ docker-compose.yml▹ docker-compose.override.yml▹ docker-compose.dev.yml▹ docker-compose.ci.yml▹ docker-compose.prod.yml

Run site with different commands.

Local:$ docker-compose up -dDev: $ docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d

See more: https://docs.docker.com/compose/extends/

30

Own cloud with Docker Swarm mode

▹ Since Docker 1.12 it supports clustering out of the box

▹ It turns a pool of Docker hosts into a single virtual Docker host

More: https://docs.docker.com/engine/swarm/

31

By the way!You can forget about server provisioning!

All you need is Docker installed on any Linux distro!

32

33

Questions?

THANK YOU! You can find me at:

taras.kiriluk

tkiriluk@gmail.com

34

top related