SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

Why Docker
Why DockerWhy Docker
Why DockerdotCloud
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionPeng Xiao
 
Docker 사내교육 자료
Docker 사내교육 자료Docker 사내교육 자료
Docker 사내교육 자료Juneyoung Oh
 
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...Edureka!
 
Introduction to Docker - IndiaOpsUG
Introduction to Docker - IndiaOpsUGIntroduction to Docker - IndiaOpsUG
Introduction to Docker - IndiaOpsUGAjeet Singh Raina
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)Gourav Varma
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with DockerRavindu Fernando
 
Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기raccoony
 
PowerShell: Automation for Everyone
PowerShell: Automation for EveryonePowerShell: Automation for Everyone
PowerShell: Automation for EveryoneIntergen
 
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
 
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command lineInstalling and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command linedotCloud
 
Docker 101: An Introduction
Docker 101: An IntroductionDocker 101: An Introduction
Docker 101: An IntroductionPOSSCON
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...Simplilearn
 
Kubernetes vs Docker Swarm | Container Orchestration War | Kubernetes Trainin...
Kubernetes vs Docker Swarm | Container Orchestration War | Kubernetes Trainin...Kubernetes vs Docker Swarm | Container Orchestration War | Kubernetes Trainin...
Kubernetes vs Docker Swarm | Container Orchestration War | Kubernetes Trainin...Edureka!
 
초심자를 위한 도커 소개 및 입문
초심자를 위한 도커 소개 및 입문초심자를 위한 도커 소개 및 입문
초심자를 위한 도커 소개 및 입문Daniel Seo
 

La actualidad más candente (20)

Dockerfile
Dockerfile Dockerfile
Dockerfile
 
Why Docker
Why DockerWhy Docker
Why Docker
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker 사내교육 자료
Docker 사내교육 자료Docker 사내교육 자료
Docker 사내교육 자료
 
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
 
Introduction to Docker - IndiaOpsUG
Introduction to Docker - IndiaOpsUGIntroduction to Docker - IndiaOpsUG
Introduction to Docker - IndiaOpsUG
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with Docker
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기
 
PowerShell: Automation for Everyone
PowerShell: Automation for EveryonePowerShell: Automation for Everyone
PowerShell: Automation for Everyone
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
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應用
Docker應用Docker應用
Docker應用
 
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command lineInstalling and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command line
 
Docker 101: An Introduction
Docker 101: An IntroductionDocker 101: An Introduction
Docker 101: An Introduction
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
 
Kubernetes vs Docker Swarm | Container Orchestration War | Kubernetes Trainin...
Kubernetes vs Docker Swarm | Container Orchestration War | Kubernetes Trainin...Kubernetes vs Docker Swarm | Container Orchestration War | Kubernetes Trainin...
Kubernetes vs Docker Swarm | Container Orchestration War | Kubernetes Trainin...
 
Docker presentation
Docker presentationDocker presentation
Docker presentation
 
초심자를 위한 도커 소개 및 입문
초심자를 위한 도커 소개 및 입문초심자를 위한 도커 소개 및 입문
초심자를 위한 도커 소개 및 입문
 

Similar a 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 a 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
 

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

Más de 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
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 

Último (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

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