SlideShare a Scribd company logo
1 of 19
Larry cai / Charlie Zha
Precondition
 You need finish/understand the basic docker knowledge
in
http://www.slideshare.net/larrycai/learn-docker-in-90-minutes
 What is docker
 Command : pull/run/images/ps ..
 Interactive and daemon mode
 Build with Dockerfile
Build Service with Docker in 90 minutes2 04/14/15
Agenda
 Docker Revisit
 Exercise 1: Revisit Dockerfile
 Exercise 2: Manage data in container (-v)
 Exercise 3: Manage data in container
from another
 Exercise 4: Link containers (--name/--
link)
 Exercise 5: Docker in Docker
 Exercise 6: Build service together
(haproxy+2 tomcat)
 Exercise 7: Docker Compose
Build Service with Docker in 90 minutes3 04/14/15
Docker HostDocker Host
HAProxy
(Load Balancer)
Tomcat
(web1)
Tomcat
(web1)
808080
8080
Web Service
Tomcat
(web2)
Tomcat
(web2)
8080
ClientClient
Environment Preparation
 Boot2docker Installer (27M)
 Contains latest docker already, fast
 Container persistence via disk automount on /var/lib/docker
 Add proxy /var/lib/boot2docker/profile if needed
 $ sudo vi /var/lib/boot2docker/profile
 export http_proxy=<your proxy>
 $ sudo /etc/init.d/docker restart
 $ docker -v
 User/Passwd: docker/tcuser
Build Service with Docker in 90 minutes4 04/14/15
http://boot2docker.io/
Environment use online service
 Create dockerVM using CoreOS image, and assign public
IP to access
 http://ustack.com or
https://cloud.digitalocean.com
 Clone code & Start them
$ ssh -i id_rsa core@42.62.73.251 # replace public IP
 Pull docker.cn/larry/tomcat if it is slow (http://docker.cn )
$ docker login docker.cn
$ docker pull docker.cn/larry/tomcat
$ docker tag docker.cn/larry/tomcat larrycai/tomcat
$ docker pull docker.cn/larry/haproxy
$ docker tag docker.cn/larry/haproxy larrycai/haproxy
Learn Ansible in Docker in 90 minutes5 04/14/15
Docker Revisit
 Docker is an open-source engine that automates the
deployment of any application as a lightweight, portable,
self-sufficient container that will run virtually anywhere.
Build Service with Docker in 90 minutes6 04/14/15
 Based on LXC (Linux
Container), easy to use.
 Similar to VM as end-
user with different
features
Manage Data in Container
 Container as a Service and Data needs persistency
 Load balancer,App, Database, Data storage
 Share data from host by mount a Host
Directory as a DataVolume
 VOLUME [ “/var/data” ] # in Dockerfile
 -v host:guest # in docker run
 Share data from another Data-only container
 --volumes-from data-container
 Backup/Restore Data-only container
Build Service with Docker in 90 minutes7 04/14/15
http://docs.docker.com/userguide/dockervolumes/
Img source from:
http://centricconsulting.com/it-shops-will-leverage-their-knowledge-
Exercise 1: Revisit Dockerfile
 Download code
$ git clone https://github.com/larrycai/docker-tomcat
 Build Service
$ vi Dockerfile
 Add proxy for apt-get
 apt-get -o Acquire::http::proxy="http://www-proxy.apac.mgmt.ericsson.se:8080 " ..
$ docker build .
Build Service with Docker in 90 minutes8 04/14/15
code https://github.com/larrycai/docker-tomcat
Exercise 2: Manage data in tomcat
 run larrycai/tomcat without volume
$ docker run -P -d larrycai/tomcat
$ docker logs <id>
 Share the local directory into it
$ docker run -v `pwd`:/var/lib/tomcat7/webapps/ -P -d
larrycai/tomcat
$ docker ps
$ docker inspect <id>
 Download sample.war
$curl
https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war
> sample.war
 Visit the service
http://192.168.59.103:<port>/sample/
Build Service with Docker in 90 minutes9 04/14/15
code https://github.com/larrycai/docker-tomcat
sample.war https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war
Exercise 3: Data container for tomcat
1. Create data container (Tips: use -e https_proxy:<proxy>)
$ docker run -v /tmp/webapps:/var/lib/tomcat7/webapps --name
webfarm jamtur01/fetcher https://tomcat.apache.org/tomcat-
7.0-doc/appdev/sample/sample.war
2. Share data from another container
$ docker run --volumes-from webfarm -P -d larrycai/tomcat
3. Try to download new one Calendar.war to put into
/tmp/wepapps
Build Service with Docker in 90 minutes10 04/14/15
Code https://github.com/jamtur01/dockerbook-code/blob/master/code/6/tomcat/fetcher/Dockerfile
Calendar.war https://gwt-examples.googlecode.com/files/Calendar.war
Link the containers in docker
 Docker container has the same private network
 Name the container and Link them to provide the service
outside and hide internal port/network !
 Name the container
docker run --name postgresql92 postgresql
 Link container to the another container
--link name:alias
docker --link postgresql92:db app
Build Service with Docker in 90 minutes11 04/14/15
http://docs.docker.com/userguide/dockerlinks/ Img source from http://lethain.com/introduction-to-
architecting-systems-for-scale/
Exercise 4: Link tomcat with haproxy
 Start tomcat with name web
$ docker run --name tomcat -d larrycai/tomcat
 Start another node with link alias
$ docker run -it --link tomcat:web 
docker/busybox
 Check environment and access it
# env # check environment
# cat /etc/hosts # check host
# wget web:8080
 Create another tomcat and Add HAProxy container
$ docker run --name tomcat1 -d larrycai/tomcat
$ docker run --name tomcat2 -d larrycai/tomcat
$ docker run --link tomcat1:back1 --link tomcat2:back2 -it -P larrycai/haproxy bash
# export CONFIG=/etc/haproxy/haproxy.cfg
# echo " server back1 ${BACK1_PORT_8080_TCP_ADDR}:8080 maxconn 32" >> $CONFIG
# echo " server back2 ${BACK2_PORT_8080_TCP_ADDR}:8080 maxconn 32" >> $CONFIG
# haproxy -f /etc/haproxy/haproxy.cfg
# ^P^Q
Access mapped 80/8080 port
Build Service with Docker in 90 minutes12 04/14/15
Docker in Docker
 Docker is client/Daemon via REMOTE API
 Docker in Docker can make environment much clean
 Docker Host only environment
 All applications are in docker container
 Easy to deployment
 Docker in Docker means install Docker Client into
Container
https://get.docker.io/builds/Linux/x86_64/docker-latest
Build Service with Docker in 90 minutes13 04/14/15
Exercise 5: Docker in Docker
 Install docker client in docker container
 Run docker command inside !!
$ docker run -it -v /var/run/docker.sock:/docker.sock larrycai/docker
bash
# docker images
 Point to Docker Host & Pass data inside
# docker -H unix:///docker.sock images
or
# export DOCKER_HOST=unix:///docker.sock
# docker images
Build Service with Docker in 90 minutes14 04/14/15
Exercise 6: Build Service Together
 Do it all
 Show the help
 Run the 2 tomcat container & Run the one haproxy container
over it.
 Show the generated port
 $ docker run larrycai/craft
Build Service with Docker in 90 minutes15 04/14/15
Docker HostDocker Host
HAProxy
(Load Balancer)
Tomcat
(web1)
Tomcat
(web1)
808080
8080
Web Service
Tomcat
(web2)
Tomcat
(web2)
8080
ClientClient
Craft
(controll)
https://github.com/larrycai/docker-images/tree/master/craft
/demo.sh/demo.sh
Docker Compose
 Compose is a tool for defining and running complex
applications with Docker.
 With Compose, you define a multi-container application
in a single file, then spin your application up in a single
command which does everything that needs to be done
to get it running.
 https://docs.docker.com/compose/
Build Service with Docker in 90 minutes16 04/14/15
Install in boot2docker
 Boot2docker can’t install compose locally, But we can
use docker in docker to access it
 Pull image
 $ docker pull dduportal/docker-compose:latest
 Set alias
 alias compose='docker run --rm -ti 
-v "$(pwd)":/app 
-v /var/run/docker.sock:/var/run/docker.sock 
dduportal/docker-compose:latest‘
https://registry.hub.docker.com/u/dduportal/docker-compose/
Build Service with Docker in 90 minutes17 04/14/15
Exercise 7(optional): Build Service With Docker
Compose
 Create the compose file
$vi docker-compose.yml
web1:
image: larrycai/tomcat:latest
web2:
image: larrycai/tomcat:latest
proxy:
image: larrycai/haproxy
ports:
- "80:8080"
links:
- web1:back1
- web2:back2
$compose up
Build Service with Docker in 90 minutes18 04/14/15
Recommend reading
 The Docker Book
 http://dockerbook.com
 Docker Docs
 https://docs.docker.com/
Build Service with Docker in 90 minutes19 04/14/15

More Related Content

What's hot

Using Docker in the Real World
Using Docker in the Real WorldUsing Docker in the Real World
Using Docker in the Real WorldTim Haak
 
Academy PRO: Docker. Lecture 4
Academy PRO: Docker. Lecture 4Academy PRO: Docker. Lecture 4
Academy PRO: Docker. Lecture 4Binary Studio
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystempsconnolly
 
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 -  Working with Wercker WorksheetsOracle Developers APAC Meetup #1 -  Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 - Working with Wercker WorksheetsDarrel Chia
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesSreenivas Makam
 
Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLarry Cai
 
What should be PID 1 in a container ? by Ranjith Rajaram for #rootConf 2017
What should be PID 1 in a container ? by Ranjith Rajaram for #rootConf 2017What should be PID 1 in a container ? by Ranjith Rajaram for #rootConf 2017
What should be PID 1 in a container ? by Ranjith Rajaram for #rootConf 2017Ranjith Rajaram
 
Containers: The What, Why, and How
Containers: The What, Why, and HowContainers: The What, Why, and How
Containers: The What, Why, and HowSneha Inguva
 
Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers Will Hall
 
Intro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and WindowsIntro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and WindowsThomas Chacko
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to DockerKuan Yen Heng
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachPROIDEA
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안양재동 코드랩
 
Solving Real World Production Problems with Docker
Solving Real World Production Problems with DockerSolving Real World Production Problems with Docker
Solving Real World Production Problems with DockerMarc Campbell
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshopRuncy Oommen
 

What's hot (20)

Using Docker in the Real World
Using Docker in the Real WorldUsing Docker in the Real World
Using Docker in the Real World
 
Academy PRO: Docker. Lecture 4
Academy PRO: Docker. Lecture 4Academy PRO: Docker. Lecture 4
Academy PRO: Docker. Lecture 4
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystem
 
A Hands-on Introduction to Docker
A Hands-on Introduction to DockerA Hands-on Introduction to Docker
A Hands-on Introduction to Docker
 
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 -  Working with Wercker WorksheetsOracle Developers APAC Meetup #1 -  Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
 
Docker
DockerDocker
Docker
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting Techniques
 
Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90mins
 
What should be PID 1 in a container ? by Ranjith Rajaram for #rootConf 2017
What should be PID 1 in a container ? by Ranjith Rajaram for #rootConf 2017What should be PID 1 in a container ? by Ranjith Rajaram for #rootConf 2017
What should be PID 1 in a container ? by Ranjith Rajaram for #rootConf 2017
 
Containers: The What, Why, and How
Containers: The What, Why, and HowContainers: The What, Why, and How
Containers: The What, Why, and How
 
Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers
 
Intro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and WindowsIntro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and Windows
 
Docker basic
Docker basicDocker basic
Docker basic
 
Docker
DockerDocker
Docker
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
 
The state of the swarm
The state of the swarmThe state of the swarm
The state of the swarm
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
Solving Real World Production Problems with Docker
Solving Real World Production Problems with DockerSolving Real World Production Problems with Docker
Solving Real World Production Problems with Docker
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 

Similar to Buildservicewithdockerin90mins

手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017Paul Chao
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇Philip Zheng
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Paul Chao
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇Philip Zheng
 
Containerizing Web Application with Docker
Containerizing Web Application with DockerContainerizing Web Application with Docker
Containerizing Web Application with Dockermsyukor
 
Docker & Kubernetes
Docker & KubernetesDocker & Kubernetes
Docker & KubernetesTroy Harvey
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Developmentmsyukor
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020CloudHero
 
Docker Networking - Boulder Linux Users Group (BLUG)
Docker Networking - Boulder Linux Users Group (BLUG)Docker Networking - Boulder Linux Users Group (BLUG)
Docker Networking - Boulder Linux Users Group (BLUG)Dan Mackin
 
BBL Premiers pas avec Docker
BBL Premiers pas avec DockerBBL Premiers pas avec Docker
BBL Premiers pas avec Dockerkanedafromparis
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerGuido Schmutz
 
Docker container a-brief_introduction_2016-01-30
Docker container a-brief_introduction_2016-01-30Docker container a-brief_introduction_2016-01-30
Docker container a-brief_introduction_2016-01-30Khelender Sasan
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsBen Hall
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutesLarry Cai
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker皓鈞 張
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Ben Hall
 
Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Nicolas Poggi
 
Apache jclouds and Docker
Apache jclouds and DockerApache jclouds and Docker
Apache jclouds and DockerAndrea Turli
 

Similar to Buildservicewithdockerin90mins (20)

手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇
 
Containerizing Web Application with Docker
Containerizing Web Application with DockerContainerizing Web Application with Docker
Containerizing Web Application with Docker
 
Docker & Kubernetes
Docker & KubernetesDocker & Kubernetes
Docker & Kubernetes
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Development
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
 
Docker Networking - Boulder Linux Users Group (BLUG)
Docker Networking - Boulder Linux Users Group (BLUG)Docker Networking - Boulder Linux Users Group (BLUG)
Docker Networking - Boulder Linux Users Group (BLUG)
 
BBL Premiers pas avec Docker
BBL Premiers pas avec DockerBBL Premiers pas avec Docker
BBL Premiers pas avec Docker
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
 
Docker container a-brief_introduction_2016-01-30
Docker container a-brief_introduction_2016-01-30Docker container a-brief_introduction_2016-01-30
Docker container a-brief_introduction_2016-01-30
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based Deployments
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 
Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]
 
moscmy2016: Extending Docker
moscmy2016: Extending Dockermoscmy2016: Extending Docker
moscmy2016: Extending Docker
 
Apache jclouds and Docker
Apache jclouds and DockerApache jclouds and Docker
Apache jclouds and Docker
 

Recently uploaded

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 

Recently uploaded (20)

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 

Buildservicewithdockerin90mins

  • 1. Larry cai / Charlie Zha
  • 2. Precondition  You need finish/understand the basic docker knowledge in http://www.slideshare.net/larrycai/learn-docker-in-90-minutes  What is docker  Command : pull/run/images/ps ..  Interactive and daemon mode  Build with Dockerfile Build Service with Docker in 90 minutes2 04/14/15
  • 3. Agenda  Docker Revisit  Exercise 1: Revisit Dockerfile  Exercise 2: Manage data in container (-v)  Exercise 3: Manage data in container from another  Exercise 4: Link containers (--name/-- link)  Exercise 5: Docker in Docker  Exercise 6: Build service together (haproxy+2 tomcat)  Exercise 7: Docker Compose Build Service with Docker in 90 minutes3 04/14/15 Docker HostDocker Host HAProxy (Load Balancer) Tomcat (web1) Tomcat (web1) 808080 8080 Web Service Tomcat (web2) Tomcat (web2) 8080 ClientClient
  • 4. Environment Preparation  Boot2docker Installer (27M)  Contains latest docker already, fast  Container persistence via disk automount on /var/lib/docker  Add proxy /var/lib/boot2docker/profile if needed  $ sudo vi /var/lib/boot2docker/profile  export http_proxy=<your proxy>  $ sudo /etc/init.d/docker restart  $ docker -v  User/Passwd: docker/tcuser Build Service with Docker in 90 minutes4 04/14/15 http://boot2docker.io/
  • 5. Environment use online service  Create dockerVM using CoreOS image, and assign public IP to access  http://ustack.com or https://cloud.digitalocean.com  Clone code & Start them $ ssh -i id_rsa core@42.62.73.251 # replace public IP  Pull docker.cn/larry/tomcat if it is slow (http://docker.cn ) $ docker login docker.cn $ docker pull docker.cn/larry/tomcat $ docker tag docker.cn/larry/tomcat larrycai/tomcat $ docker pull docker.cn/larry/haproxy $ docker tag docker.cn/larry/haproxy larrycai/haproxy Learn Ansible in Docker in 90 minutes5 04/14/15
  • 6. Docker Revisit  Docker is an open-source engine that automates the deployment of any application as a lightweight, portable, self-sufficient container that will run virtually anywhere. Build Service with Docker in 90 minutes6 04/14/15  Based on LXC (Linux Container), easy to use.  Similar to VM as end- user with different features
  • 7. Manage Data in Container  Container as a Service and Data needs persistency  Load balancer,App, Database, Data storage  Share data from host by mount a Host Directory as a DataVolume  VOLUME [ “/var/data” ] # in Dockerfile  -v host:guest # in docker run  Share data from another Data-only container  --volumes-from data-container  Backup/Restore Data-only container Build Service with Docker in 90 minutes7 04/14/15 http://docs.docker.com/userguide/dockervolumes/ Img source from: http://centricconsulting.com/it-shops-will-leverage-their-knowledge-
  • 8. Exercise 1: Revisit Dockerfile  Download code $ git clone https://github.com/larrycai/docker-tomcat  Build Service $ vi Dockerfile  Add proxy for apt-get  apt-get -o Acquire::http::proxy="http://www-proxy.apac.mgmt.ericsson.se:8080 " .. $ docker build . Build Service with Docker in 90 minutes8 04/14/15 code https://github.com/larrycai/docker-tomcat
  • 9. Exercise 2: Manage data in tomcat  run larrycai/tomcat without volume $ docker run -P -d larrycai/tomcat $ docker logs <id>  Share the local directory into it $ docker run -v `pwd`:/var/lib/tomcat7/webapps/ -P -d larrycai/tomcat $ docker ps $ docker inspect <id>  Download sample.war $curl https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war > sample.war  Visit the service http://192.168.59.103:<port>/sample/ Build Service with Docker in 90 minutes9 04/14/15 code https://github.com/larrycai/docker-tomcat sample.war https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war
  • 10. Exercise 3: Data container for tomcat 1. Create data container (Tips: use -e https_proxy:<proxy>) $ docker run -v /tmp/webapps:/var/lib/tomcat7/webapps --name webfarm jamtur01/fetcher https://tomcat.apache.org/tomcat- 7.0-doc/appdev/sample/sample.war 2. Share data from another container $ docker run --volumes-from webfarm -P -d larrycai/tomcat 3. Try to download new one Calendar.war to put into /tmp/wepapps Build Service with Docker in 90 minutes10 04/14/15 Code https://github.com/jamtur01/dockerbook-code/blob/master/code/6/tomcat/fetcher/Dockerfile Calendar.war https://gwt-examples.googlecode.com/files/Calendar.war
  • 11. Link the containers in docker  Docker container has the same private network  Name the container and Link them to provide the service outside and hide internal port/network !  Name the container docker run --name postgresql92 postgresql  Link container to the another container --link name:alias docker --link postgresql92:db app Build Service with Docker in 90 minutes11 04/14/15 http://docs.docker.com/userguide/dockerlinks/ Img source from http://lethain.com/introduction-to- architecting-systems-for-scale/
  • 12. Exercise 4: Link tomcat with haproxy  Start tomcat with name web $ docker run --name tomcat -d larrycai/tomcat  Start another node with link alias $ docker run -it --link tomcat:web docker/busybox  Check environment and access it # env # check environment # cat /etc/hosts # check host # wget web:8080  Create another tomcat and Add HAProxy container $ docker run --name tomcat1 -d larrycai/tomcat $ docker run --name tomcat2 -d larrycai/tomcat $ docker run --link tomcat1:back1 --link tomcat2:back2 -it -P larrycai/haproxy bash # export CONFIG=/etc/haproxy/haproxy.cfg # echo " server back1 ${BACK1_PORT_8080_TCP_ADDR}:8080 maxconn 32" >> $CONFIG # echo " server back2 ${BACK2_PORT_8080_TCP_ADDR}:8080 maxconn 32" >> $CONFIG # haproxy -f /etc/haproxy/haproxy.cfg # ^P^Q Access mapped 80/8080 port Build Service with Docker in 90 minutes12 04/14/15
  • 13. Docker in Docker  Docker is client/Daemon via REMOTE API  Docker in Docker can make environment much clean  Docker Host only environment  All applications are in docker container  Easy to deployment  Docker in Docker means install Docker Client into Container https://get.docker.io/builds/Linux/x86_64/docker-latest Build Service with Docker in 90 minutes13 04/14/15
  • 14. Exercise 5: Docker in Docker  Install docker client in docker container  Run docker command inside !! $ docker run -it -v /var/run/docker.sock:/docker.sock larrycai/docker bash # docker images  Point to Docker Host & Pass data inside # docker -H unix:///docker.sock images or # export DOCKER_HOST=unix:///docker.sock # docker images Build Service with Docker in 90 minutes14 04/14/15
  • 15. Exercise 6: Build Service Together  Do it all  Show the help  Run the 2 tomcat container & Run the one haproxy container over it.  Show the generated port  $ docker run larrycai/craft Build Service with Docker in 90 minutes15 04/14/15 Docker HostDocker Host HAProxy (Load Balancer) Tomcat (web1) Tomcat (web1) 808080 8080 Web Service Tomcat (web2) Tomcat (web2) 8080 ClientClient Craft (controll) https://github.com/larrycai/docker-images/tree/master/craft /demo.sh/demo.sh
  • 16. Docker Compose  Compose is a tool for defining and running complex applications with Docker.  With Compose, you define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running.  https://docs.docker.com/compose/ Build Service with Docker in 90 minutes16 04/14/15
  • 17. Install in boot2docker  Boot2docker can’t install compose locally, But we can use docker in docker to access it  Pull image  $ docker pull dduportal/docker-compose:latest  Set alias  alias compose='docker run --rm -ti -v "$(pwd)":/app -v /var/run/docker.sock:/var/run/docker.sock dduportal/docker-compose:latest‘ https://registry.hub.docker.com/u/dduportal/docker-compose/ Build Service with Docker in 90 minutes17 04/14/15
  • 18. Exercise 7(optional): Build Service With Docker Compose  Create the compose file $vi docker-compose.yml web1: image: larrycai/tomcat:latest web2: image: larrycai/tomcat:latest proxy: image: larrycai/haproxy ports: - "80:8080" links: - web1:back1 - web2:back2 $compose up Build Service with Docker in 90 minutes18 04/14/15
  • 19. Recommend reading  The Docker Book  http://dockerbook.com  Docker Docs  https://docs.docker.com/ Build Service with Docker in 90 minutes19 04/14/15