Top Banner
Gerald Z. Villorente, VielSoft Ltd Co. Drupal | Linux | DevOps | FOSS Advocate | Father Drupal Camp Vietnam 2016, Hanoi University of Science and Technology - Hanoi, Vietnam Of Docker and Drupal customizable and reusable environment
48

Of Docker and Drupal

Apr 11, 2017

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Of Docker and Drupal

Gerald Z. Villorente, VielSoft Ltd Co.Drupal | Linux | DevOps | FOSS Advocate | Father

Drupal Camp Vietnam 2016, Hanoi University of Science and Technology - Hanoi, Vietnam

Of Docker and Drupal

customizable and reusable environment

Page 2: Of Docker and Drupal

About Me | V tôiề

● Drupal developer● Linux enthusiast ● Advocate of free education● Managing Director, VielSoft Ltd Co.● Docker and OpenStack enthusiast● DevOps● Beer● A father

Page 3: Of Docker and Drupal
Page 4: Of Docker and Drupal
Page 5: Of Docker and Drupal

Introducing DockerGi i thi u Dockerớ ệ

Page 6: Of Docker and Drupal

What is Docker?Docker là gì?

Page 7: Of Docker and Drupal

So what Docker is?

Docker allows you to package an application with all of its dependencies into a standardized unit for software development.

Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server.

This guarantees that it will always run the same, regardless of the environment it is running in.

Page 8: Of Docker and Drupal
Page 9: Of Docker and Drupal

What is a Container?Container là gì??

is a set of processes which have been isolated together by the Linux kernel

Page 10: Of Docker and Drupal

Why Docker?T i sao Docker?ạ

Page 11: Of Docker and Drupal

Lightweight

Tr ng lư ng nhọ ợ ẹ

Page 12: Of Docker and Drupal

Portable

di đ ngộ

Page 13: Of Docker and Drupal

Isolation

Bi t l pệ ậ

Page 14: Of Docker and Drupal

Consistent Environments

môi trư ng phù h pờ ợ

Page 15: Of Docker and Drupal

Developer: Build Once, Run Anywhere

● A clean, safe, hygienic and portable runtime environment for your app.● No worries about missing dependencies, packages and other pain

points during subsequent deployments.● Run each app in its isolated container.● Automate testing, integration, packaging...anything you can script● Reduce/eliminate concerns about compatibility on different platforms,

either your own or your customers.● Install replay and reset of image snapshots.● Almost no overhead (think about VM).

Page 16: Of Docker and Drupal

DevOps: Configure Once, Run Anything

● Make the entire lifecycle more efficient, consistent, and repeatable.● Increase the quality of code produced by developers.● Eliminate inconsistencies between development, test, production,

and customer environments.● Support segregation of duties.● Significantly improves the speed and reliability of continuous

deployment and continuous integration systems.● Because the containers are so lightweight, address significant

performance, costs, deployment, and portability issues normally associated with VMs.

Page 17: Of Docker and Drupal
Page 18: Of Docker and Drupal

Dockerfile

A Dockerfile is a text document that contains all the commands a user could call on the command line to

assemble an image.

Page 19: Of Docker and Drupal

How to check the existence of Docker Engine?

Làm th nào đ ki m tra s t n ế ể ể ự ồt i c a Docker Engine?ạ ủ

Page 20: Of Docker and Drupal

How to check Docker version?Làm th nào đ ki m tra phiên ế ể ể

b n Docker?ả

Page 21: Of Docker and Drupal

Working with Docker ImagesLàm vi c v i Dockerệ ớ

Page 22: Of Docker and Drupal

How to create an image?Làm th nào đ t o ra m t ế ể ạ ộ

image?

$ cd [DOCKERFILE-DIR]

$ docker build .

Page 23: Of Docker and Drupal

How to pull a pre-built image?Làm th nào đ pull m t image ế ể ộ

đư c xây d ng trư c?ợ ự ớ

$ docker pull geraldvillorente/ubuntu-base

Page 24: Of Docker and Drupal

How to rebuild the image?Làm th nào đ xây d ng l i ế ể ự ạ

image?

$ docker build --no-cache .

Or

$ docker build -t geraldvillorente/drupal7:3.0 .

Page 25: Of Docker and Drupal

How to list Docker images?Làm th nào đ li t kê các image ế ể ệ

Docker?

$ docker images

Page 26: Of Docker and Drupal

How to delete an image?Làm th nào đ xóa image?ế ể

$ docker rmi [IMAGE_ID]

Page 27: Of Docker and Drupal

How to create a version?Làm th nào đ t o ra m t phiên ế ể ạ ộ

b n?ả

$ docker tag [IMAGE ID] geraldvillorente/drupal7:latest

$ docker tag [IMAGE ID] geraldvillorente/drupal7:2.0

Page 28: Of Docker and Drupal

How to push to a remote repository?

Làm th nào đ push đ n m t ế ể ế ộkho lưu tr t xa?ữ ừ

$ docker login

$ docker push geraldvillorente/drupal7:2.2

Page 29: Of Docker and Drupal

Working with Docker ContainersLàm vi c v i Docker Containersệ ớ

Page 30: Of Docker and Drupal

How to create Docker container?Làm th nào đ t o ra Docker ế ể ạ

container?

$ docker run [IMAGE_ID]

$ docker run --name d7memcache -d [IMAGE_ID]

Where “d7memcache” is the name of the container and

“-d” is to tell Docker to run the “d7memcache” container in background and “[IMAGE_ID]” is the Docker image that we want to load in the container.

Page 31: Of Docker and Drupal

How to SSH in Docker container?Làm th nào đ SSH vào Docker ế ể

container?

$ docker exec -it [CONTAINER_ID] bin/bash

Or

$ docker exec -it [CONTAINER_NAME] bin/bash

Page 32: Of Docker and Drupal

How to link Docker containers?Làm th nào đ liên k t Docker ế ể ế

container?$ docker run --name db_d7_vietnam -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6

Where “db_d7_vietnam” is the name of the container and “123456” is root password and “mysql:5.6” is the Docker image.

$ docker run --name web_apache2 --link db_d7_vietnam:db_d7_vietnam -d -p 49980:80 -v /home/gerald/Web/drupal7/www:/var/www/html [WEB_IMAGE_ID]

Where “web_apache2” is the name of the web app and “49980” is the http port mapped to port 80 of the web container and “/home/gerald/Web/drupal7/www” is the location of Drupal project and “/var/www/html” is the mount point inside Docker container and “[WEB_IMAGE_ID]” is the ID of Docker image containing Apache and PHP stuff.

Page 33: Of Docker and Drupal

How to stop a container?Làm th nào đ d ng m t ế ể ừ ộ

container?

$ docker stop [CONTAINER_ID]

Or

$ docker stop [CONTAINER_NAME]

Page 34: Of Docker and Drupal

How to start a container?Làm th nào đ b t đ u m t ế ể ắ ầ ộ

container?

$ docker start [CONTAINER_ID]

Or

$ docker start [CONTAINER_NAME]

Page 35: Of Docker and Drupal

How to inspect a container?Làm th nào đ ki m tra m t ế ể ể ộ

container?$ docker inspect [CONTAINER_ID]

Or

$ docker inspect [CONTAINER_NAME]

# Checking linked container/s

$ docker inspect -f "{{ .HostConfig.Links }}" [CONTAINER_ID]

# Checking environment variables

$ docker inspect -f "{{ .Config.Env }}" [CONTAINER_ID]

Page 36: Of Docker and Drupal

How to check container logs?Làm th nào đ ki m tra các ế ể ể

container log?

$ docker logs [CONTAINER_ID]

Page 37: Of Docker and Drupal

How to check container processes?

Làm th nào đ ki m tra quá ế ể ểtrình container?

$ docker top [CONTAINER_ID]

Page 38: Of Docker and Drupal

How to delete a container?Làm th nào đ xóa m t ế ể ộ

container?

$ docker rm [CONTAINER_ID]

Page 39: Of Docker and Drupal

How to list Docker containers?Làm th nào đ li t kê Docker ế ể ệ

containers?# To list running containers

$ docker ps

# To list all containers

$ docker ps -a

Page 40: Of Docker and Drupal

Accessing the App?Truy c p ng d ng?ậ ứ ụ

Page 41: Of Docker and Drupal

http://localhost:49980

Page 42: Of Docker and Drupal

Assigning VHOST to Docker Ports?

Gán VHOST đ n c ng Docker ?ế ổ

Page 43: Of Docker and Drupal

http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/

Page 44: Of Docker and Drupal

In case you need more helpTrong trư ng h p b n c n thêm ờ ợ ạ ầ

tr giúpợ

● https://training.docker.com/● http://learningdocker.com/● https://github.com/dwyl/learn-docker● https://www.youtube.com/watch?v=Q5POuMHxW-0● https://www.youtube.com/watch?v=VeiUjkiqo9E● http://build-podcast.com/docker/

Page 45: Of Docker and Drupal

Question?Câu h i?ỏ

Page 46: Of Docker and Drupal

Contact | Liên Hệ

● Skype : gerald.villorente● Website: https://vielsoft.com● Hangout : [email protected]● Email: [email protected]● Github: https://github.com/VielSoft● Facebook: https://fb.com/VielSoft● Mobile: +639167332641

Page 47: Of Docker and Drupal

Thank you | SalamatC m ơn b nả ạ

Page 48: Of Docker and Drupal

Disclaimer

All images and other content used in this presentation are borrowed from the internet. Therefore, all rights reserved to the original

owner.