SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
Larry cai
Charlie Zha zysimplelife AT gmail.com
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 09/16/16
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 09/16/16
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 09/16/16
http://boot2docker.io/
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 minutes5 09/16/16
 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 minutes6 09/16/16
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
$ docker build .
Build Service with Docker in 90 minutes7 09/16/16
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 minutes8 09/16/16
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 minutes9 09/16/16
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 minutes10 09/16/16
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.cn/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 minutes11 09/16/16
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 minutes12 09/16/16
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 minutes13 09/16/16
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 minutes14 09/16/16
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 minutes15 09/16/16
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 minutes16 09/16/16
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 minutes17 09/16/16
Recommend reading
 The Docker Book
 http://dockerbook.com
 Docker Docs
 https://docs.docker.com/
Build Service with Docker in 90 minutes18 09/16/16

Más contenido relacionado

La actualidad más candente

파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Composeraccoony
 
PHP development with Docker
PHP development with DockerPHP development with Docker
PHP development with DockerYosh de Vos
 
How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with dockerRuoshi Ling
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Paul Chao
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017Paul Chao
 
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)Ruoshi Ling
 
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/20146 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014Christian Beedgen
 
Running Django on Docker: a workflow and code
Running Django on Docker: a workflow and codeRunning Django on Docker: a workflow and code
Running Django on Docker: a workflow and codeDanielle Madeley
 
Docker Distributed application bundle & Stack - Overview
Docker Distributed application bundle & Stack - Overview Docker Distributed application bundle & Stack - Overview
Docker Distributed application bundle & Stack - Overview Thomas Chacko
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with DockerGeeta Vinnakota
 
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...Docker, Inc.
 
Docker workshop DevOpsDays Amsterdam 2014
Docker workshop DevOpsDays Amsterdam 2014Docker workshop DevOpsDays Amsterdam 2014
Docker workshop DevOpsDays Amsterdam 2014Pini Reznik
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeSoshi Nemoto
 
Buildservicewithdockerin90mins
Buildservicewithdockerin90minsBuildservicewithdockerin90mins
Buildservicewithdockerin90minsYong Cha
 
Docker & JVM: A Perfect Match
Docker & JVM: A Perfect MatchDocker & JVM: A Perfect Match
Docker & JVM: A Perfect MatchMatthias Grüter
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with DockerPatrick Mizer
 

La actualidad más candente (20)

파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
PHP development with Docker
PHP development with DockerPHP development with Docker
PHP development with Docker
 
How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with docker
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
 
A Hands-on Introduction to Docker
A Hands-on Introduction to DockerA Hands-on Introduction to Docker
A Hands-on Introduction to Docker
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017
 
Docker
DockerDocker
Docker
 
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
 
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/20146 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
 
Running Django on Docker: a workflow and code
Running Django on Docker: a workflow and codeRunning Django on Docker: a workflow and code
Running Django on Docker: a workflow and code
 
Docker Distributed application bundle & Stack - Overview
Docker Distributed application bundle & Stack - Overview Docker Distributed application bundle & Stack - Overview
Docker Distributed application bundle & Stack - Overview
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 
Exploring Docker Security
Exploring Docker SecurityExploring Docker Security
Exploring Docker Security
 
ABCs of docker
ABCs of dockerABCs of docker
ABCs of docker
 
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
 
Docker workshop DevOpsDays Amsterdam 2014
Docker workshop DevOpsDays Amsterdam 2014Docker workshop DevOpsDays Amsterdam 2014
Docker workshop DevOpsDays Amsterdam 2014
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_code
 
Buildservicewithdockerin90mins
Buildservicewithdockerin90minsBuildservicewithdockerin90mins
Buildservicewithdockerin90mins
 
Docker & JVM: A Perfect Match
Docker & JVM: A Perfect MatchDocker & JVM: A Perfect Match
Docker & JVM: A Perfect Match
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
 

Destacado

Dan Lockton Behavior Design Amsterdam New Year 2016
Dan Lockton Behavior Design Amsterdam New Year 2016Dan Lockton Behavior Design Amsterdam New Year 2016
Dan Lockton Behavior Design Amsterdam New Year 2016Behavior Design AMS
 
Defeating The Network Security Infrastructure V1.0
Defeating The Network Security Infrastructure  V1.0Defeating The Network Security Infrastructure  V1.0
Defeating The Network Security Infrastructure V1.0Philippe Bogaerts
 
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAPVirtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAPMichael Coates
 
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...KubeAcademy
 
Kumpulan Soal Seni Budaya SMA/SMK beserta Jawaban
Kumpulan Soal Seni Budaya SMA/SMK beserta JawabanKumpulan Soal Seni Budaya SMA/SMK beserta Jawaban
Kumpulan Soal Seni Budaya SMA/SMK beserta JawabanDavid Adi Nugroho
 

Destacado (6)

Command
CommandCommand
Command
 
Dan Lockton Behavior Design Amsterdam New Year 2016
Dan Lockton Behavior Design Amsterdam New Year 2016Dan Lockton Behavior Design Amsterdam New Year 2016
Dan Lockton Behavior Design Amsterdam New Year 2016
 
Defeating The Network Security Infrastructure V1.0
Defeating The Network Security Infrastructure  V1.0Defeating The Network Security Infrastructure  V1.0
Defeating The Network Security Infrastructure V1.0
 
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAPVirtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
 
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
 
Kumpulan Soal Seni Budaya SMA/SMK beserta Jawaban
Kumpulan Soal Seni Budaya SMA/SMK beserta JawabanKumpulan Soal Seni Budaya SMA/SMK beserta Jawaban
Kumpulan Soal Seni Budaya SMA/SMK beserta Jawaban
 

Similar a Build service with_docker_in_90mins

Docker & Kubernetes
Docker & KubernetesDocker & Kubernetes
Docker & KubernetesTroy Harvey
 
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
 
Containerizing Web Application with Docker
Containerizing Web Application with DockerContainerizing Web Application with Docker
Containerizing Web Application with Dockermsyukor
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇Philip Zheng
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇Philip Zheng
 
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
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutesLarry Cai
 
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
 
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
 
BBL Premiers pas avec Docker
BBL Premiers pas avec DockerBBL Premiers pas avec Docker
BBL Premiers pas avec Dockerkanedafromparis
 
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
 
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
 
Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4Binary Studio
 
Docker Swarm & Machine
Docker Swarm & MachineDocker Swarm & Machine
Docker Swarm & MachineEueung Mulyana
 
Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Nicolas Poggi
 

Similar a Build service with_docker_in_90mins (20)

Docker & Kubernetes
Docker & KubernetesDocker & Kubernetes
Docker & Kubernetes
 
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
 
Containerizing Web Application with Docker
Containerizing Web Application with DockerContainerizing Web Application with Docker
Containerizing Web Application with Docker
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 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
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
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
 
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)
 
BBL Premiers pas avec Docker
BBL Premiers pas avec DockerBBL Premiers pas avec Docker
BBL Premiers pas avec Docker
 
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
 
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
 
Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4
 
Docker by Example - Quiz
Docker by Example - QuizDocker by Example - Quiz
Docker by Example - Quiz
 
Docker by Example - Quiz
Docker by Example - QuizDocker by Example - Quiz
Docker by Example - Quiz
 
DevOps: Docker Workshop
DevOps: Docker WorkshopDevOps: Docker Workshop
DevOps: Docker Workshop
 
Docker Swarm & Machine
Docker Swarm & MachineDocker Swarm & Machine
Docker Swarm & Machine
 
Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 

Más de Larry Cai

Learn kubernetes in 90 minutes
Learn kubernetes in 90 minutesLearn kubernetes in 90 minutes
Learn kubernetes in 90 minutesLarry Cai
 
Learn jobDSL for Jenkins
Learn jobDSL for JenkinsLearn jobDSL for Jenkins
Learn jobDSL for JenkinsLarry Cai
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90minsLarry Cai
 
Learn ELK in docker
Learn ELK in dockerLearn ELK in docker
Learn ELK in dockerLarry Cai
 
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer TalkLarry Cai
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90minsLarry Cai
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using dockerLarry Cai
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLarry Cai
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with PythonLarry Cai
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90minsLarry Cai
 
Lead changes in software development
Lead changes in software developmentLead changes in software development
Lead changes in software developmentLarry Cai
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90minsLarry Cai
 
Practical way to experience of Specification by Example
Practical way to experience of Specification by ExamplePractical way to experience of Specification by Example
Practical way to experience of Specification by ExampleLarry Cai
 
Experience from specification_by_examples
Experience from specification_by_examplesExperience from specification_by_examples
Experience from specification_by_examplesLarry Cai
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdownLarry Cai
 
Continuous Integration Introduction
Continuous Integration IntroductionContinuous Integration Introduction
Continuous Integration IntroductionLarry Cai
 
Agile & ALM tools
Agile & ALM toolsAgile & ALM tools
Agile & ALM toolsLarry Cai
 

Más de Larry Cai (17)

Learn kubernetes in 90 minutes
Learn kubernetes in 90 minutesLearn kubernetes in 90 minutes
Learn kubernetes in 90 minutes
 
Learn jobDSL for Jenkins
Learn jobDSL for JenkinsLearn jobDSL for Jenkins
Learn jobDSL for Jenkins
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90mins
 
Learn ELK in docker
Learn ELK in dockerLearn ELK in docker
Learn ELK in docker
 
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer Talk
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90mins
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90mins
 
Lead changes in software development
Lead changes in software developmentLead changes in software development
Lead changes in software development
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90mins
 
Practical way to experience of Specification by Example
Practical way to experience of Specification by ExamplePractical way to experience of Specification by Example
Practical way to experience of Specification by Example
 
Experience from specification_by_examples
Experience from specification_by_examplesExperience from specification_by_examples
Experience from specification_by_examples
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdown
 
Continuous Integration Introduction
Continuous Integration IntroductionContinuous Integration Introduction
Continuous Integration Introduction
 
Agile & ALM tools
Agile & ALM toolsAgile & ALM tools
Agile & ALM tools
 

Último

TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDSTYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDSedrianrheine
 
Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024Shubham Pant
 
Bio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptxBio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptxnaveenithkrishnan
 
Presentation2.pptx - JoyPress Wordpress
Presentation2.pptx -  JoyPress WordpressPresentation2.pptx -  JoyPress Wordpress
Presentation2.pptx - JoyPress Wordpressssuser166378
 
Computer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a WebsiteComputer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a WebsiteMavein
 
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced HorizonsVision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced HorizonsRoxana Stingu
 
Zero-day Vulnerabilities
Zero-day VulnerabilitiesZero-day Vulnerabilities
Zero-day Vulnerabilitiesalihassaah1994
 
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...APNIC
 
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024Jan Löffler
 
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdfLESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdfmchristianalwyn
 
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdfIntroduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdfShreedeep Rayamajhi
 
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASSLESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASSlesteraporado16
 

Último (12)

TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDSTYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
 
Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024
 
Bio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptxBio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptx
 
Presentation2.pptx - JoyPress Wordpress
Presentation2.pptx -  JoyPress WordpressPresentation2.pptx -  JoyPress Wordpress
Presentation2.pptx - JoyPress Wordpress
 
Computer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a WebsiteComputer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a Website
 
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced HorizonsVision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
 
Zero-day Vulnerabilities
Zero-day VulnerabilitiesZero-day Vulnerabilities
Zero-day Vulnerabilities
 
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
 
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
 
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdfLESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
 
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdfIntroduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdf
 
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASSLESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
 

Build service with_docker_in_90mins

  • 1. Larry cai Charlie Zha zysimplelife AT gmail.com
  • 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 09/16/16
  • 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 09/16/16 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 09/16/16 http://boot2docker.io/
  • 5. 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 minutes5 09/16/16  Based on LXC (Linux Container), easy to use.  Similar to VM as end- user with different features
  • 6. 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 minutes6 09/16/16 http://docs.docker.com/userguide/dockervolumes/ Img source from: http://centricconsulting.com/it-shops-will-leverage-their-knowledge-
  • 7. Exercise 1: Revisit Dockerfile  Download code $ git clone https://github.com/larrycai/docker-tomcat  Build Service $ vi Dockerfile $ docker build . Build Service with Docker in 90 minutes7 09/16/16 code https://github.com/larrycai/docker-tomcat
  • 8. 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 minutes8 09/16/16 code https://github.com/larrycai/docker-tomcat sample.war https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war
  • 9. 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 minutes9 09/16/16 Code https://github.com/jamtur01/dockerbook-code/blob/master/code/6/tomcat/fetcher/Dockerfile Calendar.war https://gwt-examples.googlecode.com/files/Calendar.war
  • 10. 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 minutes10 09/16/16 http://docs.docker.com/userguide/dockerlinks/ Img source from http://lethain.com/introduction-to- architecting-systems-for-scale/
  • 11. 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.cn/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 minutes11 09/16/16
  • 12. 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 minutes12 09/16/16
  • 13. 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 minutes13 09/16/16
  • 14. 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 minutes14 09/16/16 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
  • 15. 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 minutes15 09/16/16
  • 16. 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 minutes16 09/16/16
  • 17. 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 minutes17 09/16/16
  • 18. Recommend reading  The Docker Book  http://dockerbook.com  Docker Docs  https://docs.docker.com/ Build Service with Docker in 90 minutes18 09/16/16