SlideShare a Scribd company logo
1 of 20
Learn Docker in 90 minutes
Larry cai <larry.caiyu@gmail.com>
Agenda
 Introduction
 Exercise 1: First docker container
 Exercise 2: Add package and create own docker
image
 Exercise 3: Understand layer
 Exercise 4: Expose the service
 Exercise 5: Dockerfile to build
 Exercise 6: Share your image with others
 Reference
Learn docker in 90 minutes2 7/27/2017
Environment Preparation
 Docker toolbox
 Contains latest docker already, fast
 Container persistence via disk automount on /var/lib/docker
 Create docker host in virtualbox
 Quickstart to get default
 Verify the installation
$ docker-machine ssh
$ docker –v
 Optional way
$ docker-machine ip
 SSH to docker server using IP
 User/Passwd: docker/tcuser
Learn docker in 90 minutes3 7/27/2017
https://github.com/docker/toolbox/releases Windows
7
https://www.docker.com/docker-windows Windows
10
Environment online
 Docker labs: http://labs.play-with-docker.com
 Exposed port will be automatically visible as link
 One terminal shell for one instance, create another
instance and ssh to have another terminal
 Exercise 3 can’t be done
Learn docker in 90 minutes4 7/27/2017
Note: recommend to use Local env instead of online
Introduction
 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.
Learn docker in 90 minutes5 7/27/2017
 Based on LXC (Linux
Container), easy to
use.
 Similar to VM as end-
user with different
features
Exercise 1: First docker container
 Download from central place for ubuntu
$ docker search ubuntu # from lots of release in internet
$ docker pull ubuntu
Pulling repository ubuntu
ad892dd21d60: Pulling dependent layers
511136ea3c5a: Pulling fs layer
$ docker images # list local images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu latest ad892dd21d60 6 days ago 275.5 MB
 Execute command directly
$ docker run ubuntu echo “Hello World”
 Interactive with container (-i : interactive, -t: tty)
$ docker run -i -t ubuntu bash
# uname –a
# dpkg –l
Learn docker in 90 minutes6 7/27/2017
`docker` - the command line tool
 Some common commands:
 $ docker search # search hub.docker.com for an image
 $ docker pull # download image
 $ docker images # list all existing local images
 $ docker run # initiates a container from an image
 $ docker ps # list running containers
 $ docker build # build images from Dockerfile
 $ docker start/stop/kill # commands
 $ docker rm/rmi to remove a container or image
Learn docker in 90 minutes7 7/27/2017
http://superuser.com/questions/756999/whats-the-difference-between-docker-stop-and-docker-kill
Exercise 2: Add own package and image
 Try to install apache2 inside
$ docker run -i -t ubuntu bash
# apt-get update && apt-get install -y apache2
# exit
$ docker ps –l # -l means –latest
CONTAINER ID IMAGE COMMAND CREATED STATUS
c4bd63cc87f1 ubuntu:latest bash 2 minutes ago Exited 2 sec
$ docker commit <container id> apache2
66db661d9ad8681b082bb62b21b6ef5f2ddb4799e3df5dbd8fb23aed16616b1d
 Check and run it again to see if the apache is there
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
apache2 latest 66db661d9ad8 28 seconds ago 298.5 MB
ubuntu latest ad892dd21d60 6 days ago 275.5 MB
$ docker run -i -t apache2 bash
 Question: Apache binary & Process exists ?
Learn docker in 90 minutes8 7/27/2017
Docker image & layer
 Docker images are saved in layered !!
 Differed binary for apache2 image
 See the image tree
$ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz images -t
└─511136ea3c5a Virtual Size: 0 B
└─e465fff03bce Virtual Size: 192.5 MB
└─23f361102fae Virtual Size: 192.7 MB
└─9db365ecbcbb Virtual Size: 192.7 MB
└─ad892dd21d60 Virtual Size: 275.5 MB Tags: ubuntu:latest
└─66db661d9ad8 Virtual Size: 298.5 MB Tags: apache2:latest
Learn docker in 90 minutes9 7/27/2017
http://docs.docker.io/terms/layer/
Note: For -v /var/run/docker.sock:/var/run/docker.sock, It is docker in docker technology, see
https://github.com/justone/dockviz (not important for beginner, focus on layer)
Docker image & layer
 When Docker mounts the rootfs, it
starts read-only, it takes
advantage of a union
mount (aufs) to add a read-write
file system over the read-only file
system.
 There may be multiple read-only
file systems stacked on top of
each other. We think of each one
of these file systems as a layer.
Learn docker in 90 minutes10 7/27/2017
http://docs.docker.io/terms/layer/
Exercise 3: Understand the layer
 Try
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz images -t
 Data are stored under /var/lib/docker (root
permission)
 aufs is used in boot2docker, could be others like
devicemapper
$ sudo su -
# ls -1 /var/lib/docker/aufs/diff/
..
66db661d9ad8681b082bb62b21b6ef5f2ddb4799e3df5dbd8fb23aed16616b1d/
9db365ecbcbbb20e063eac70842c53e27fcad0e213f9d4ddb78152339cedd3b1/
 See what is diff inside /var/lib/docker/aufs/diff !!
# find /var/lib/docker/aufs/diff | grep apache2
# cd /var/lib/docker/aufs/diff/<edeb8e0e3…> # replace with id
# find .
Learn docker in 90 minutes11 7/27/2017
See more https://docs.docker.com/engine/userguide/storagedriver/imagesandconta
Note: This works in Windows, can’t be done under http://labs.play-with-
docker.com
Skip this if lack of time
Docker service
 Network in container is not visible outside (using
NAT)
 The service is exposed by Port !!
 Run –p host:guest # assign port to host
 $ docker run –p 25890:80 –i –t apache2 bash
 # apache2ctl start
Learn docker in 90 minutes12 7/27/2017
source from : http://pierre-jean.baraud.fr/blog/2014/06/02/host-docker-
containers/
Docker service
 Interactive mode vs. Daemon (Deattach) mode
(docker run)
-d : run in daemon mode
-i : run in interactive mode
 Enter into existing docker container
$ docker exec -it <container ID> bash
Learn docker in 90 minutes13 7/27/2017
Exercise 4: Expose the service
 Export the port to host as 25890 and start the service
manually
$ docker run -p 25890:80 –i -t apache2 bash
root@35ac981a49e5:/# service apache2 start
$ docker ps # in another shell (docker-machine ssh)
CONTAINER ID IMAGE …. STATUS PORTS NAMES
e020aa2c02a5 apache2:latest ….. Up 14 seconds 0.0.0.0:25890->80/tcp web
$ curl http://localhost:25890 # or use 192.168.99.100 to replace localhost
 Come into the container again to check
$ docker exec –it e020aa2c02a5 bash
# ps –ef # check apache process
 Run contain in daemon mode and access 25891
$ docker run –p 25891:80 –d –t apache2 apache2ctl –D FOREGROUND
 Access it in shell & local browser
 Challenge: can you access your friend’s web page ?
Learn docker in 90 minutes14 7/27/2017
Port forward to Localhost in Windows
 Use boot2docker VM IP to
access
 $ docker-machine ip default
 http://192.168.99.100:25890
 Use Virtualbox
 25890 is visible in VM
 8080 is visible in Host
(Windows)
 http://localhost:8080
Learn docker in 90 minutes15 7/27/2017
Dockerfile
 Dockerfile instructs on how to build the image
automatically
 Dockerfile Syntax (INSTRUCTION arguments)
 FROM – defines base image
 RUN - executes arbitrary command
ENV – sets environment
 EXPOSE – expose a port
 ADD – add local file
 CMD – default command to execute
 MAINTAINER – author information
 Used by docker build
Learn docker in 90 minutes16 7/27/2017
Exercise 5: Dockerfile apache2/wget
 Create the Dockerfile
$ vi /tmp/Dockerfile
$
$ cd /tmp
$ docker build –t wget .
 Start the wget image and verify !!
Learn docker in 90 minutes17 7/27/2017
Share images in docker repository
 Docker is also a tool for sharing. A repository is a
shareable collection of tagged images that together
create the file systems for containers.
 Public repo. <username>/<repo_name>
 Trusted image
 $ docker search/pull/login/push
Learn docker in 90 minutes18 7/27/2017
http://docs.docker.com/docker-hub/repos/
Summary
 This is getting started training slides, door is open to
you.
 Benefit and use case will be added with your
growing competence
 Docker grows very fast, follow it.
Learn docker in 90 minutes19 7/27/2017
ChangeLog
 2014/12/31: docker exec instead of attach, MacOS,
Add books
 2016/09/06: docker image layers are different since
1.10
 2017/07/27: update to latest version 17.06
Learn docker in 90 minutes20 7/27/2017

More Related Content

What's hot

Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to dockerJohn Willis
 
Docker introduction for the beginners
Docker introduction for the beginnersDocker introduction for the beginners
Docker introduction for the beginnersJuneyoung Oh
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & IntroductionLee Trout
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionPeng Xiao
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefitsAmit Manwade
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to KubernetesImesh Gunaratne
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker ComposeAjeet Singh Raina
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageejlp12
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for BeginnerShahzad Masud
 
Docker Networking Deep Dive
Docker Networking Deep DiveDocker Networking Deep Dive
Docker Networking Deep DiveDocker, Inc.
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)Gourav Varma
 
Dockers and containers basics
Dockers and containers basicsDockers and containers basics
Dockers and containers basicsSourabh Saxena
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...Edureka!
 

What's hot (20)

Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Docker introduction for the beginners
Docker introduction for the beginnersDocker introduction for the beginners
Docker introduction for the beginners
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & Introduction
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefits
 
Final terraform
Final terraformFinal terraform
Final terraform
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to Kubernetes
 
Terraform
TerraformTerraform
Terraform
 
[9월 런치 세미나] 도커와 쿠버네티스 기술에 스며들다
[9월 런치 세미나] 도커와 쿠버네티스 기술에 스며들다[9월 런치 세미나] 도커와 쿠버네티스 기술에 스며들다
[9월 런치 세미나] 도커와 쿠버네티스 기술에 스며들다
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker Compose
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and image
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
DevOps with Kubernetes
DevOps with KubernetesDevOps with Kubernetes
DevOps with Kubernetes
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for Beginner
 
Docker Networking Deep Dive
Docker Networking Deep DiveDocker Networking Deep Dive
Docker Networking Deep Dive
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)
 
Dockers and containers basics
Dockers and containers basicsDockers and containers basics
Dockers and containers basics
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Advanced Terraform
Advanced TerraformAdvanced Terraform
Advanced Terraform
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
 

Similar to Learn docker in 90 minutes

Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with dockerGiacomo Bagnoli
 
Docker in Action
Docker in ActionDocker in Action
Docker in ActionAlper Kanat
 
Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Nicolas Poggi
 
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 for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortalsHenryk Konsek
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017Paul Chao
 
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth RushgroveThe Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth RushgroveDocker, Inc.
 
Docker workshop
Docker workshopDocker workshop
Docker workshopEvans Ye
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇Philip Zheng
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90minsLarry Cai
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Paul Chao
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇Philip Zheng
 
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
 
Docker for Deep Learning (Andrea Panizza)
Docker for Deep Learning (Andrea Panizza)Docker for Deep Learning (Andrea Panizza)
Docker for Deep Learning (Andrea Panizza)MeetupDataScienceRoma
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 augVincent De Smet
 
Into to Docker (Central PA Java User Group - 8/14/2017)
Into to Docker (Central PA Java User Group - 8/14/2017)Into to Docker (Central PA Java User Group - 8/14/2017)
Into to Docker (Central PA Java User Group - 8/14/2017)Mike Melusky
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 applicationRoman Rodomansky
 

Similar to Learn docker in 90 minutes (20)

Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
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
 
A Hands-on Introduction to Docker
A Hands-on Introduction to DockerA Hands-on Introduction to Docker
A Hands-on Introduction to Docker
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017
 
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth RushgroveThe Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90mins
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 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)
 
Docker for Deep Learning (Andrea Panizza)
Docker for Deep Learning (Andrea Panizza)Docker for Deep Learning (Andrea Panizza)
Docker for Deep Learning (Andrea Panizza)
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
 
Into to Docker (Central PA Java User Group - 8/14/2017)
Into to Docker (Central PA Java User Group - 8/14/2017)Into to Docker (Central PA Java User Group - 8/14/2017)
Into to Docker (Central PA Java User Group - 8/14/2017)
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
 

More from 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 RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLarry 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
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesLarry 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
 

More from Larry Cai (19)

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 RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90mins
 
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
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
 
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
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Learn docker in 90 minutes

  • 1. Learn Docker in 90 minutes Larry cai <larry.caiyu@gmail.com>
  • 2. Agenda  Introduction  Exercise 1: First docker container  Exercise 2: Add package and create own docker image  Exercise 3: Understand layer  Exercise 4: Expose the service  Exercise 5: Dockerfile to build  Exercise 6: Share your image with others  Reference Learn docker in 90 minutes2 7/27/2017
  • 3. Environment Preparation  Docker toolbox  Contains latest docker already, fast  Container persistence via disk automount on /var/lib/docker  Create docker host in virtualbox  Quickstart to get default  Verify the installation $ docker-machine ssh $ docker –v  Optional way $ docker-machine ip  SSH to docker server using IP  User/Passwd: docker/tcuser Learn docker in 90 minutes3 7/27/2017 https://github.com/docker/toolbox/releases Windows 7 https://www.docker.com/docker-windows Windows 10
  • 4. Environment online  Docker labs: http://labs.play-with-docker.com  Exposed port will be automatically visible as link  One terminal shell for one instance, create another instance and ssh to have another terminal  Exercise 3 can’t be done Learn docker in 90 minutes4 7/27/2017 Note: recommend to use Local env instead of online
  • 5. Introduction  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. Learn docker in 90 minutes5 7/27/2017  Based on LXC (Linux Container), easy to use.  Similar to VM as end- user with different features
  • 6. Exercise 1: First docker container  Download from central place for ubuntu $ docker search ubuntu # from lots of release in internet $ docker pull ubuntu Pulling repository ubuntu ad892dd21d60: Pulling dependent layers 511136ea3c5a: Pulling fs layer $ docker images # list local images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest ad892dd21d60 6 days ago 275.5 MB  Execute command directly $ docker run ubuntu echo “Hello World”  Interactive with container (-i : interactive, -t: tty) $ docker run -i -t ubuntu bash # uname –a # dpkg –l Learn docker in 90 minutes6 7/27/2017
  • 7. `docker` - the command line tool  Some common commands:  $ docker search # search hub.docker.com for an image  $ docker pull # download image  $ docker images # list all existing local images  $ docker run # initiates a container from an image  $ docker ps # list running containers  $ docker build # build images from Dockerfile  $ docker start/stop/kill # commands  $ docker rm/rmi to remove a container or image Learn docker in 90 minutes7 7/27/2017 http://superuser.com/questions/756999/whats-the-difference-between-docker-stop-and-docker-kill
  • 8. Exercise 2: Add own package and image  Try to install apache2 inside $ docker run -i -t ubuntu bash # apt-get update && apt-get install -y apache2 # exit $ docker ps –l # -l means –latest CONTAINER ID IMAGE COMMAND CREATED STATUS c4bd63cc87f1 ubuntu:latest bash 2 minutes ago Exited 2 sec $ docker commit <container id> apache2 66db661d9ad8681b082bb62b21b6ef5f2ddb4799e3df5dbd8fb23aed16616b1d  Check and run it again to see if the apache is there $ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE apache2 latest 66db661d9ad8 28 seconds ago 298.5 MB ubuntu latest ad892dd21d60 6 days ago 275.5 MB $ docker run -i -t apache2 bash  Question: Apache binary & Process exists ? Learn docker in 90 minutes8 7/27/2017
  • 9. Docker image & layer  Docker images are saved in layered !!  Differed binary for apache2 image  See the image tree $ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz images -t └─511136ea3c5a Virtual Size: 0 B └─e465fff03bce Virtual Size: 192.5 MB └─23f361102fae Virtual Size: 192.7 MB └─9db365ecbcbb Virtual Size: 192.7 MB └─ad892dd21d60 Virtual Size: 275.5 MB Tags: ubuntu:latest └─66db661d9ad8 Virtual Size: 298.5 MB Tags: apache2:latest Learn docker in 90 minutes9 7/27/2017 http://docs.docker.io/terms/layer/ Note: For -v /var/run/docker.sock:/var/run/docker.sock, It is docker in docker technology, see https://github.com/justone/dockviz (not important for beginner, focus on layer)
  • 10. Docker image & layer  When Docker mounts the rootfs, it starts read-only, it takes advantage of a union mount (aufs) to add a read-write file system over the read-only file system.  There may be multiple read-only file systems stacked on top of each other. We think of each one of these file systems as a layer. Learn docker in 90 minutes10 7/27/2017 http://docs.docker.io/terms/layer/
  • 11. Exercise 3: Understand the layer  Try docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz images -t  Data are stored under /var/lib/docker (root permission)  aufs is used in boot2docker, could be others like devicemapper $ sudo su - # ls -1 /var/lib/docker/aufs/diff/ .. 66db661d9ad8681b082bb62b21b6ef5f2ddb4799e3df5dbd8fb23aed16616b1d/ 9db365ecbcbbb20e063eac70842c53e27fcad0e213f9d4ddb78152339cedd3b1/  See what is diff inside /var/lib/docker/aufs/diff !! # find /var/lib/docker/aufs/diff | grep apache2 # cd /var/lib/docker/aufs/diff/<edeb8e0e3…> # replace with id # find . Learn docker in 90 minutes11 7/27/2017 See more https://docs.docker.com/engine/userguide/storagedriver/imagesandconta Note: This works in Windows, can’t be done under http://labs.play-with- docker.com Skip this if lack of time
  • 12. Docker service  Network in container is not visible outside (using NAT)  The service is exposed by Port !!  Run –p host:guest # assign port to host  $ docker run –p 25890:80 –i –t apache2 bash  # apache2ctl start Learn docker in 90 minutes12 7/27/2017 source from : http://pierre-jean.baraud.fr/blog/2014/06/02/host-docker- containers/
  • 13. Docker service  Interactive mode vs. Daemon (Deattach) mode (docker run) -d : run in daemon mode -i : run in interactive mode  Enter into existing docker container $ docker exec -it <container ID> bash Learn docker in 90 minutes13 7/27/2017
  • 14. Exercise 4: Expose the service  Export the port to host as 25890 and start the service manually $ docker run -p 25890:80 –i -t apache2 bash root@35ac981a49e5:/# service apache2 start $ docker ps # in another shell (docker-machine ssh) CONTAINER ID IMAGE …. STATUS PORTS NAMES e020aa2c02a5 apache2:latest ….. Up 14 seconds 0.0.0.0:25890->80/tcp web $ curl http://localhost:25890 # or use 192.168.99.100 to replace localhost  Come into the container again to check $ docker exec –it e020aa2c02a5 bash # ps –ef # check apache process  Run contain in daemon mode and access 25891 $ docker run –p 25891:80 –d –t apache2 apache2ctl –D FOREGROUND  Access it in shell & local browser  Challenge: can you access your friend’s web page ? Learn docker in 90 minutes14 7/27/2017
  • 15. Port forward to Localhost in Windows  Use boot2docker VM IP to access  $ docker-machine ip default  http://192.168.99.100:25890  Use Virtualbox  25890 is visible in VM  8080 is visible in Host (Windows)  http://localhost:8080 Learn docker in 90 minutes15 7/27/2017
  • 16. Dockerfile  Dockerfile instructs on how to build the image automatically  Dockerfile Syntax (INSTRUCTION arguments)  FROM – defines base image  RUN - executes arbitrary command ENV – sets environment  EXPOSE – expose a port  ADD – add local file  CMD – default command to execute  MAINTAINER – author information  Used by docker build Learn docker in 90 minutes16 7/27/2017
  • 17. Exercise 5: Dockerfile apache2/wget  Create the Dockerfile $ vi /tmp/Dockerfile $ $ cd /tmp $ docker build –t wget .  Start the wget image and verify !! Learn docker in 90 minutes17 7/27/2017
  • 18. Share images in docker repository  Docker is also a tool for sharing. A repository is a shareable collection of tagged images that together create the file systems for containers.  Public repo. <username>/<repo_name>  Trusted image  $ docker search/pull/login/push Learn docker in 90 minutes18 7/27/2017 http://docs.docker.com/docker-hub/repos/
  • 19. Summary  This is getting started training slides, door is open to you.  Benefit and use case will be added with your growing competence  Docker grows very fast, follow it. Learn docker in 90 minutes19 7/27/2017
  • 20. ChangeLog  2014/12/31: docker exec instead of attach, MacOS, Add books  2016/09/06: docker image layers are different since 1.10  2017/07/27: update to latest version 17.06 Learn docker in 90 minutes20 7/27/2017