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

도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!pyrasis
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Herofazalraja
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking OverviewSreenivas Makam
 
Docker Registry V2
Docker Registry V2Docker Registry V2
Docker Registry V2Docker, Inc.
 
Docker introduction for the beginners
Docker introduction for the beginnersDocker introduction for the beginners
Docker introduction for the beginnersJuneyoung Oh
 
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Simplilearn
 
Docker introduction
Docker introductionDocker introduction
Docker introductiondotCloud
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with DockerRavindu Fernando
 
Dockers and containers basics
Dockers and containers basicsDockers and containers basics
Dockers and containers basicsSourabh Saxena
 
Building .NET Microservices
Building .NET MicroservicesBuilding .NET Microservices
Building .NET MicroservicesVMware Tanzu
 
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!
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js선협 이
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with SpringJoshua Long
 
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!
 
Docker Container Security
Docker Container SecurityDocker Container Security
Docker Container SecuritySuraj Khetani
 
Intégration continue et déploiement continue avec Jenkins
Intégration continue et déploiement continue avec JenkinsIntégration continue et déploiement continue avec Jenkins
Intégration continue et déploiement continue avec JenkinsKokou Gaglo
 
NGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX, Inc.
 

La actualidad más candente (20)

도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking Overview
 
Docker Registry V2
Docker Registry V2Docker Registry V2
Docker Registry V2
 
Docker introduction for the beginners
Docker introduction for the beginnersDocker introduction for the beginners
Docker introduction for the beginners
 
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with Docker
 
Dockers and containers basics
Dockers and containers basicsDockers and containers basics
Dockers and containers basics
 
Building .NET Microservices
Building .NET MicroservicesBuilding .NET Microservices
Building .NET Microservices
 
Introduction to container based virtualization with docker
Introduction to container based virtualization with dockerIntroduction to container based virtualization with docker
Introduction to container based virtualization with docker
 
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...
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
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...
 
presentation on Docker
presentation on Dockerpresentation on Docker
presentation on Docker
 
Docker Container Security
Docker Container SecurityDocker Container Security
Docker Container Security
 
Docker
DockerDocker
Docker
 
Intégration continue et déploiement continue avec Jenkins
Intégration continue et déploiement continue avec JenkinsIntégration continue et déploiement continue avec Jenkins
Intégration continue et déploiement continue avec Jenkins
 
NGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX: Basics and Best Practices
NGINX: Basics and Best Practices
 

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

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

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Último (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

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