SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Why Docker
Why DockerWhy Docker
Why DockerdotCloud
 
Docker Birthday #3 - Intro to Docker Slides
Docker Birthday #3 - Intro to Docker SlidesDocker Birthday #3 - Intro to Docker Slides
Docker Birthday #3 - Intro to Docker SlidesDocker, Inc.
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for BeginnerShahzad Masud
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker, Inc.
 
A Hands-On Introduction To Docker Containers.pdf
A Hands-On Introduction To Docker Containers.pdfA Hands-On Introduction To Docker Containers.pdf
A Hands-On Introduction To Docker Containers.pdfEdith Puclla
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersYajushi Srivastava
 
Présentation de Vagrant
Présentation de VagrantPrésentation de Vagrant
Présentation de Vagrantclmntlxndr
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction Robert Reiz
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to DockerAditya Konarde
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins PipelinesSteffen Gebert
 
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Edureka!
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slidesDocker, Inc.
 
Kubernetes & helm 활용
Kubernetes & helm 활용Kubernetes & helm 활용
Kubernetes & helm 활용SK Telecom
 
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...Edureka!
 

Was ist angesagt? (20)

Why Docker
Why DockerWhy Docker
Why Docker
 
What is Docker
What is DockerWhat is Docker
What is Docker
 
Docker Birthday #3 - Intro to Docker Slides
Docker Birthday #3 - Intro to Docker SlidesDocker Birthday #3 - Intro to Docker Slides
Docker Birthday #3 - Intro to Docker Slides
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for Beginner
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016
 
A Hands-On Introduction To Docker Containers.pdf
A Hands-On Introduction To Docker Containers.pdfA Hands-On Introduction To Docker Containers.pdf
A Hands-On Introduction To Docker Containers.pdf
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
 
Présentation de Vagrant
Présentation de VagrantPrésentation de Vagrant
Présentation de Vagrant
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
What is Docker?
What is Docker?What is Docker?
What is Docker?
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Docker應用
Docker應用Docker應用
Docker應用
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Kubernetes & helm 활용
Kubernetes & helm 활용Kubernetes & helm 활용
Kubernetes & helm 활용
 
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
 

Ähnlich wie Learn Docker in 90 minutes: Docker containers, images, Dockerfile & more

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
 
Buildservicewithdockerin90mins
Buildservicewithdockerin90minsBuildservicewithdockerin90mins
Buildservicewithdockerin90minsYong Cha
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshopRuncy Oommen
 

Ähnlich wie Learn Docker in 90 minutes: Docker containers, images, Dockerfile & more (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
 
Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]
 
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
 
Buildservicewithdockerin90mins
Buildservicewithdockerin90minsBuildservicewithdockerin90mins
Buildservicewithdockerin90mins
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix 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
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Kürzlich hochgeladen (20)

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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Learn Docker in 90 minutes: Docker containers, images, Dockerfile & more

  • 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