Of Docker and Drupal
-
Upload
gerald-villorente -
Category
Software
-
view
490 -
download
1
Transcript of 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
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
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.
What is a Container?Container là gì??
is a set of processes which have been isolated together by the Linux kernel
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).
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.
Dockerfile
A Dockerfile is a text document that contains all the commands a user could call on the command line to
assemble an image.
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?ạ ủ
How to create an image?Làm th nào đ t o ra m t ế ể ạ ộ
image?
$ cd [DOCKERFILE-DIR]
$ docker build .
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
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 .
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
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
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.
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
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.
How to stop a container?Làm th nào đ d ng m t ế ể ừ ộ
container?
$ docker stop [CONTAINER_ID]
Or
$ docker stop [CONTAINER_NAME]
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]
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]
How to check container logs?Làm th nào đ ki m tra các ế ể ể
container log?
$ docker logs [CONTAINER_ID]
How to check container processes?
Làm th nào đ ki m tra quá ế ể ểtrình container?
$ docker top [CONTAINER_ID]
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
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/
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