Docker для чайників. Просто про складне. Використання для локальної розробки. Як Docker може спростити автоматизацію CI Workflow. Досвід використання на реальних Drupal проектах.
2. Hi @here!
I am Taras Kyryliuk
I 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
7. 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
12. ”
Docker is an open-source engine that
automates the deployment of applications
into containers.
12
13. ”
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
14. ▹The Docker client and server
▹Docker Images
▹Registries
▹Docker Containers
14 Docker components
16. “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
23. 3. Docker in Drupal development
What problems we can solve using it.
23
24. 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
25. 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 3306
mysql>
25
http://severalnines.com/blog/mysql-docker-containers-understanding-basics
26. Container as a Service
(MySQL as an example)26
http://severalnines.com/blog/mysql-docker-containers-understanding-basics
27. 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
28. 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
30. DEV-STAGE-PROD env
with Docker Compose
You 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 -d
Dev:
$ docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
See more: https://docs.docker.com/compose/extends/
30
31. 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
32. By the way!
You can forget about server provisioning!
All you need is Docker installed on any Linux
distro!
32