SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
Docker
From walking to running
Giacomo Vacca, RTCSoft, gv@rtcsoft.net 1
About me
• 15 years “in the trenches cubicles”
• Developer of RTC (VoIP, IM, WebRTC) solutions
• Often dealing with DevOps topics
• Founder of RTCSoft in 2015
@giavac
https://github.com/giavac
gv@rtcsoft.net
2
Docker usage scenarios
• Run (micro)services
• Deployment mechanism
• Prototyping
• Testing
• Continuous Integration/Delivery
3
What’s in a name?
4
Previously on this show 1/2
http://www.slideshare.net/GiacomoVacca/docker-and-puppet-for-continuous-integration
5
Previously on this show 2/2
http://www.slideshare.net/GiacomoVacca/docker-from-scratch
6
What is Docker, really?
• An Open-Source (Go) framework to manage “container virtualisation” (started in 2013)
• Docker isolates multiple user spaces (file systems) inside the same host
• The user space instances are called “Containers”
• They give you the illusion of being inside a VM
• Think about “execution environments” or “sandboxes”
• No need for an hypervisor (and so very quick to launch)
• Requires x64 Linux and kernel 3.8+
• Google started dev of cgroups for the Linux kernel, then together with namespaces and chroot become LXC
7
Main Docker components
• Engine: manages images and containers. Exposes an API
• Client: connects to the Engine (locally or remotely)
• Compose: manages multi-container architectures
• Swarm: orchestrates containers on multiple hosts
• Kitematic: GUI for Docker client
• Machine: provision and manage VMs to host containers
8
Ingredients vs Cake
9
Virtual Machines vs Docker
Source: https://www.docker.com/what-docker
10
What Docker is not?
• A programming language
• An OS
• A Virtual Machine
• An image in the traditional hypervisor-based Virtual Machine concept
11
Where is Docker used?
• Uber, eBay, BBC News, shopify, ING, Swisscom, Groupon (1)
• and many others…
• Supported by Google Cloud Platform
• with the Container Engine + Kubernetes
(1) source: https://www.docker.com/customers
12
Who should know about Docker?
• Developers
• Including mobile developers
• Sysadmins
• “DevOps” people
• Architects/CTO/COO
13
Basic topics
• Images and Containers
• Image structure
• Dockerfiles
• Building an image
• Interacting with an image repo
• Running a container
14
• Architecture
• Typical Linux vs Toolbox
• Volumes
• Port mapping
Some advanced topics
• Inspecting/debugging containers
• inspect/attach/exec/logs/top
• Volumes, data containers
• Multicontainer architectures
• Link, network, Compose
• Docker inside Docker
• Is it worth it? Consider the “sibling” approach (“socket mounting”) instead.
• Orchestrating Docker containers via Puppet
15
Inspect a Container
docker inspect CONTAINER_NAME
Formatting options, e.g.:
docker inspect --format='{{range .NetworkSettings.Networks}}
{{.IPAddress}}{{end}}' CONTAINER_ID
16
Output of inspect
{
"Id": "c61b85d3a9451d2ac3bbe301f54dc97b0df13c2835d0fb1f6214db64929e646d",
"Created": "2016-01-05T09:47:16.125279193Z",
"Path": "/bin/sh",
"Args": [
"-c",
"nginx"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 16817,
…
17
Debugging a container
$ docker info
$ docker attach CONTAINER_NAME
$ docker exec -it CONTAINER_NAME COMMAND
e.g. ‘$ docker exec -it gvacca/nginx /bin/bash’
$ docker logs CONTAINER_NAME
Or show processes running inside a container:
$ docker top CONTAINER_NAME
18
Volumes
• Share a folder between host and container
• VOLUME commands inside the Dockerfile
• Dynamic volume association at run time: one or more ‘-v’ arguments
• Volumes shared by an image are available even if the container is
not running (but it needs to still exist).
19
Multicontainer architecture
• Define many containers (aka “services”)
• Define relationship between them (e.g. “depends on”)
• Define networking
• Start/Stop all services at the same time
20
Networks of Containers
• “docker network” defined since Docker 1.9
• Create a virtual network, then attach containers to it
• Containers on different networks by default don’t see each other
• Internal private addressing, managed by Docker
• Brilliant for prototyping and emulating entire architectures
21
Docker network
• ‘docker network create NAME’
• ‘docker network attach NAME CONTAINER’
• ‘docker network ls’
• ‘docker network inspect NAME’
22
Docker Compose
• docker-compose.yml, defines a set of containers (“services”). Written in python,
available with Toolbox.
• Define their runtime properties (images, volumes, ports, dependencies)
• Interact with registries (public/private)
• Network
• Containers can be located with a name, instead of IP address (e.g ‘https://
mysql_server:3306’, from 1.6.2)
• Default name is ‘APPFOLDER_default’
23
Compose main commands
• ‘docker-compose build [service]’
• ’docker-compose [--verbose] up [-d]’
• ‘docker-compose start [service]’
• ‘docker-compose down’
• ‘docker-compose top’
24
Docker Machine
• Provision and manage VMs
• Available with Toolbox (uses Virtualbox)
• ‘docker-machine active’
• ‘docker-machine ls’
• ‘docker-machine start default’
• eval $(docker-machine env)
25
Let’s play with Docker Compose
• Write your docker-compose.yml file
• ’docker-compose build [service]’
• Builds the images when needed (‘build’), or exits (‘image’)
• ’docker-compose up’
• Add ‘-d’ to run in background (daemon mode)
• ‘docker ps’ to see the launched containers
• ‘docker-compose ps’
• See the processes and other details - similar to ‘docker ps’
• ‘docker-compose down/stop/kill’
• To switch off the node
26
The Workshop
• Create a simple app with 2 containers
• One with stock image
• One with built image
• Run and inspect
• Check volumes
• Create the same app with Compose
• Run and inspect
• Check network and volumes
27
Compose scenario - steps
Browse to http://192.168.99.100:5000/
docker-compose --verbose up
Browse to http://192.168.99.100:5000/
CTRL+C
docker-compose --verbose up -d
docker ps | grep 'composetest'
docker-compose ps
docker-compose --verbose ps
docker network ls |grep 'composetest'
docker network inspect 'composetest_default'
python inspect_docker_network.py 'composetest_default'
28
docker ps
Giacomos-MacBook-Pro:docker-experiments gv$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
PORTS NAMES
13398ae967e5 gvacca/kamailio_async:ubuntu14 "tail -f /dev/null" 3 months ago Up 3 seconds
5060/tcp dockerexperiments_kamailio_async_ubuntu_1
51c8105ef7ab gvacca/kamailio_async:centos7 "tail -f /dev/null" 3 months ago Up 3 seconds
5060/tcp dockerexperiments_kamailio_async_centos_1
4e21f9fd9694 gvacca/sipp "tail -f /dev/null" 3 months ago Up 3 seconds
dockerexperiments_sipp_1
381272e54d19 gvacca/nginx_ssl "/bin/sh -c nginx" 3 months ago Up 3 seconds
80/tcp, 443/tcp dockerexperiments_nginx_ssl_1
29
docker inspect http_network
[
{
"Name": "http_network",
"Id": "29c9951bf3fbaaa73f5a0fa39a4de1c65fbbe99f0aef8b49718a921ab6deed17",
"Scope": "local",
"Driver": "bridge",
"IPAM": {
"Driver": "default",
"Config": [
{}
]
},
"Containers": {
"13398ae967e5ba0677cd151bda64c4458671b335dd46d67c7f4ef01b8b65821b": {
"EndpointID": "18ebb70df95e24cec9932f9925c655fa9866aa34e2a8a40e90827ba3bea8441d",
"MacAddress": "02:42:ac:13:00:05",
"IPv4Address": "172.19.0.5/16",
"IPv6Address": ""
},
"381272e54d19f24c6c3f923e3f35e8676d2fd19ab229fb3a382893c889367c42": {
"EndpointID": "abd412f88e83b6e8460b222f3aa293dd6f118f8d54a29403e1a68f27a22a5d43",
"MacAddress": "02:42:ac:13:00:02",
"IPv4Address": "172.19.0.2/16",
"IPv6Address": ""
},
"4e21f9fd9694a50a9ff42f0cae11ea1e208b72ec21a539014284082b5887c57f": {
"EndpointID": "2a5e7d1800ddb55f7c4192d819aff413b024a2d0e97be612ca000497d23d80bf",
"MacAddress": "02:42:ac:13:00:03",
"IPv4Address": "172.19.0.3/16",
"IPv6Address": ""
},
"51c8105ef7ab8079cf05428a83ea7f6c6395a2a5fc08075617d855992a27492f": {
"EndpointID": "5871de671429a51b52f8b498410d5ffe394e95ceccc8ac6d2dadf9b139727821",
"MacAddress": "02:42:ac:13:00:04",
"IPv4Address": "172.19.0.4/16",
"IPv6Address": ""
}
30
Scripting with docker APIs
$ python inspect_docker_network.py http_network
13398ae967e5ba0677cd151bda64c4458671b335dd46d67c7f4ef01b8b65821b '/dockerexperiments_kamailio_async_ubuntu_1': 172.19.0.5/16
4e21f9fd9694a50a9ff42f0cae11ea1e208b72ec21a539014284082b5887c57f '/dockerexperiments_sipp_1': 172.19.0.3/16
381272e54d19f24c6c3f923e3f35e8676d2fd19ab229fb3a382893c889367c42 '/dockerexperiments_nginx_ssl_1': 172.19.0.2/16
51c8105ef7ab8079cf05428a83ea7f6c6395a2a5fc08075617d855992a27492f '/dockerexperiments_kamailio_async_centos_1': 172.19.0.4/16
31
inspect_docker_network.py
#!/usr/bin/python
# Get the output of 'docker network inspect' for a given network
# and return containers names and their IP address
import json
import subprocess
import sys
network_name = sys.argv[1]
network_json = subprocess.check_output(["docker", "network", "inspect", network_name])
network = json.loads(network_json)
containers = network[0]['Containers']
for container_id in containers:
container_name = subprocess.check_output(["docker", "inspect", "--format",
"'{{ .Name }}'", container_id])
print container_id + " " + container_name.strip() + ": " + containers[container_id]
['IPv4Address']
32
Cleaning up
• docker rm CONTAINER
• docker rmi IMAGE
• docker rmi $(docker images -q --filter "dangling=true")
33
Questions and Answers
Thanks
34
Recommended Books
• “The Docker book”, J. Turnbull, http://www.amazon.co.uk/Docker-Book-
Containerization-new-virtualization-ebook/dp/B00LRROTI4
• “Using Docker”, A. Mouat, O’Reilly, https://www.amazon.co.uk/Using-Docker-
Adrian-Mouat/dp/1491915765
• “Continuous Delivery”, J. Humble, http://www.amazon.com/Continuous-Delivery-
Deployment-Automation-Addison-Wesley/dp/0321601912
• “Building Microservices”, S. Newman, http://shop.oreilly.com/product/
0636920033158.do
• "Docker Networking and Service Discovery", O’Reilly, https://www.nginx.com/
resources/library/docker-networking/
35
Other useful references
• https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-
for-ci/
• https://www.dajobe.org/blog/2015/04/18/making-debian-docker-
images-smaller/
• http://blog.replicated.com/2016/02/05/refactoring-a-dockerfile-for-
image-size/
36

Weitere ähnliche Inhalte

Was ist angesagt?

Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefMatt Ray
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshopRuncy Oommen
 
Basic docker for developer
Basic docker for developerBasic docker for developer
Basic docker for developerWeerayut Hongsa
 
Docker for Java Developers
Docker for Java DevelopersDocker for Java Developers
Docker for Java DevelopersNGINX, Inc.
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutesLarry Cai
 
99cloud Docker Training module 2
99cloud Docker Training module 299cloud Docker Training module 2
99cloud Docker Training module 2Liang Bo
 
Docker and Containers for Development and Deployment — SCALE12X
Docker and Containers for Development and Deployment — SCALE12XDocker and Containers for Development and Deployment — SCALE12X
Docker and Containers for Development and Deployment — SCALE12XJérôme Petazzoni
 
Docker module 1
Docker module 1Docker module 1
Docker module 1Liang Bo
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in developmentAdam Culp
 
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16 What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16 Docker, Inc.
 
Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and AgentRanjit Avasarala
 
Docker Continuous Delivery Workshop
Docker Continuous Delivery WorkshopDocker Continuous Delivery Workshop
Docker Continuous Delivery WorkshopJirayut Nimsaeng
 
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...dotCloud
 
Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Chris Tankersley
 
Docker from A to Z, including Swarm and OCCS
Docker from A to Z, including Swarm and OCCSDocker from A to Z, including Swarm and OCCS
Docker from A to Z, including Swarm and OCCSFrank Munz
 
Docker 101 @KACST Saudi HPC 2016
Docker 101  @KACST Saudi HPC 2016Docker 101  @KACST Saudi HPC 2016
Docker 101 @KACST Saudi HPC 2016Walid Shaari
 
Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9 Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9 Jérôme Petazzoni
 
Docker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochraneDocker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochranedotCloud
 

Was ist angesagt? (20)

A Hands-on Introduction to Docker
A Hands-on Introduction to DockerA Hands-on Introduction to Docker
A Hands-on Introduction to Docker
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and Chef
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 
Basic docker for developer
Basic docker for developerBasic docker for developer
Basic docker for developer
 
Docker for Java Developers
Docker for Java DevelopersDocker for Java Developers
Docker for Java Developers
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
99cloud Docker Training module 2
99cloud Docker Training module 299cloud Docker Training module 2
99cloud Docker Training module 2
 
Docker and Containers for Development and Deployment — SCALE12X
Docker and Containers for Development and Deployment — SCALE12XDocker and Containers for Development and Deployment — SCALE12X
Docker and Containers for Development and Deployment — SCALE12X
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in development
 
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16 What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
 
Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and Agent
 
Docker Continuous Delivery Workshop
Docker Continuous Delivery WorkshopDocker Continuous Delivery Workshop
Docker Continuous Delivery Workshop
 
Docker - introduction
Docker - introductionDocker - introduction
Docker - introduction
 
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
 
Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017
 
Docker from A to Z, including Swarm and OCCS
Docker from A to Z, including Swarm and OCCSDocker from A to Z, including Swarm and OCCS
Docker from A to Z, including Swarm and OCCS
 
Docker 101 @KACST Saudi HPC 2016
Docker 101  @KACST Saudi HPC 2016Docker 101  @KACST Saudi HPC 2016
Docker 101 @KACST Saudi HPC 2016
 
Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9 Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9
 
Docker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochraneDocker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken Cochrane
 

Ähnlich wie Docker - From Walking To Running

Docker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notesDocker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notesSreenivas Makam
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Herofazalraja
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 applicationRoman Rodomansky
 
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and JenkinsExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and JenkinsElasTest Project
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 PresentationSreenivas Makam
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안양재동 코드랩
 
Cohesion Techsessie Docker - Daniel Palstra
Cohesion Techsessie Docker - Daniel PalstraCohesion Techsessie Docker - Daniel Palstra
Cohesion Techsessie Docker - Daniel PalstraDaniel Palstra
 
Tech talk on docker with demo
Tech talk on docker with demoTech talk on docker with demo
Tech talk on docker with demoSandeep Karnawat
 
Intro docker and demo monitor on docker
Intro docker and demo monitor on dockerIntro docker and demo monitor on docker
Intro docker and demo monitor on dockerWatcharin Yang-Ngam
 
Docker DANS workshop
Docker DANS workshopDocker DANS workshop
Docker DANS workshopvty
 
Dockerize the World - presentation from Hradec Kralove
Dockerize the World - presentation from Hradec KraloveDockerize the World - presentation from Hradec Kralove
Dockerize the World - presentation from Hradec Kralovedamovsky
 
Using Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and JenkinsUsing Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and JenkinsMicael Gallego
 
Powercoders · Docker · Fall 2021.pptx
Powercoders · Docker · Fall 2021.pptxPowercoders · Docker · Fall 2021.pptx
Powercoders · Docker · Fall 2021.pptxIgnacioTamayo2
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with DockerGeeta Vinnakota
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Paul Chao
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇Philip Zheng
 

Ähnlich wie Docker - From Walking To Running (20)

Docker, but what it is?
Docker, but what it is?Docker, but what it is?
Docker, but what it is?
 
Docker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notesDocker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notes
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
 
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and JenkinsExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
 
Containerization using docker and its applications
Containerization using docker and its applicationsContainerization using docker and its applications
Containerization using docker and its applications
 
Containerization using docker and its applications
Containerization using docker and its applicationsContainerization using docker and its applications
Containerization using docker and its applications
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
Cohesion Techsessie Docker - Daniel Palstra
Cohesion Techsessie Docker - Daniel PalstraCohesion Techsessie Docker - Daniel Palstra
Cohesion Techsessie Docker - Daniel Palstra
 
Tech talk on docker with demo
Tech talk on docker with demoTech talk on docker with demo
Tech talk on docker with demo
 
Intro docker and demo monitor on docker
Intro docker and demo monitor on dockerIntro docker and demo monitor on docker
Intro docker and demo monitor on docker
 
Docker DANS workshop
Docker DANS workshopDocker DANS workshop
Docker DANS workshop
 
Dockerize the World - presentation from Hradec Kralove
Dockerize the World - presentation from Hradec KraloveDockerize the World - presentation from Hradec Kralove
Dockerize the World - presentation from Hradec Kralove
 
Docker Ecosystem on Azure
Docker Ecosystem on AzureDocker Ecosystem on Azure
Docker Ecosystem on Azure
 
Using Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and JenkinsUsing Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and Jenkins
 
Powercoders · Docker · Fall 2021.pptx
Powercoders · Docker · Fall 2021.pptxPowercoders · Docker · Fall 2021.pptx
Powercoders · Docker · Fall 2021.pptx
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇
 

Mehr von Giacomo Vacca

Modern VoIP in modern infrastructures
Modern VoIP in modern infrastructuresModern VoIP in modern infrastructures
Modern VoIP in modern infrastructuresGiacomo Vacca
 
Modern VoIP in Modern Infrastructures
Modern VoIP in Modern InfrastructuresModern VoIP in Modern Infrastructures
Modern VoIP in Modern InfrastructuresGiacomo Vacca
 
An SFU/MCU integration for heterogeneous environments
An SFU/MCU integration for heterogeneous environmentsAn SFU/MCU integration for heterogeneous environments
An SFU/MCU integration for heterogeneous environmentsGiacomo Vacca
 
Kamailio World 2018 - Workshop: kamailio-tests
Kamailio World 2018 - Workshop: kamailio-testsKamailio World 2018 - Workshop: kamailio-tests
Kamailio World 2018 - Workshop: kamailio-testsGiacomo Vacca
 
Homer - Workshop at Kamailio World 2017
Homer - Workshop at Kamailio World 2017Homer - Workshop at Kamailio World 2017
Homer - Workshop at Kamailio World 2017Giacomo Vacca
 
[workshop] The Revolutionary WebRTC
[workshop] The Revolutionary WebRTC[workshop] The Revolutionary WebRTC
[workshop] The Revolutionary WebRTCGiacomo Vacca
 
Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationGiacomo Vacca
 
Top 5 Challenges To Add Web Calls to Truphone VoIP Platform
Top 5 Challenges To Add Web Calls to Truphone VoIP PlatformTop 5 Challenges To Add Web Calls to Truphone VoIP Platform
Top 5 Challenges To Add Web Calls to Truphone VoIP PlatformGiacomo Vacca
 
Automatic Kamailio Deployments With Puppet
Automatic Kamailio Deployments With PuppetAutomatic Kamailio Deployments With Puppet
Automatic Kamailio Deployments With PuppetGiacomo Vacca
 

Mehr von Giacomo Vacca (11)

STUN protocol
STUN protocolSTUN protocol
STUN protocol
 
Modern VoIP in modern infrastructures
Modern VoIP in modern infrastructuresModern VoIP in modern infrastructures
Modern VoIP in modern infrastructures
 
RIPP Notes
RIPP NotesRIPP Notes
RIPP Notes
 
Modern VoIP in Modern Infrastructures
Modern VoIP in Modern InfrastructuresModern VoIP in Modern Infrastructures
Modern VoIP in Modern Infrastructures
 
An SFU/MCU integration for heterogeneous environments
An SFU/MCU integration for heterogeneous environmentsAn SFU/MCU integration for heterogeneous environments
An SFU/MCU integration for heterogeneous environments
 
Kamailio World 2018 - Workshop: kamailio-tests
Kamailio World 2018 - Workshop: kamailio-testsKamailio World 2018 - Workshop: kamailio-tests
Kamailio World 2018 - Workshop: kamailio-tests
 
Homer - Workshop at Kamailio World 2017
Homer - Workshop at Kamailio World 2017Homer - Workshop at Kamailio World 2017
Homer - Workshop at Kamailio World 2017
 
[workshop] The Revolutionary WebRTC
[workshop] The Revolutionary WebRTC[workshop] The Revolutionary WebRTC
[workshop] The Revolutionary WebRTC
 
Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous Integration
 
Top 5 Challenges To Add Web Calls to Truphone VoIP Platform
Top 5 Challenges To Add Web Calls to Truphone VoIP PlatformTop 5 Challenges To Add Web Calls to Truphone VoIP Platform
Top 5 Challenges To Add Web Calls to Truphone VoIP Platform
 
Automatic Kamailio Deployments With Puppet
Automatic Kamailio Deployments With PuppetAutomatic Kamailio Deployments With Puppet
Automatic Kamailio Deployments With Puppet
 

Kürzlich hochgeladen

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Kürzlich hochgeladen (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Docker - From Walking To Running

  • 1. Docker From walking to running Giacomo Vacca, RTCSoft, gv@rtcsoft.net 1
  • 2. About me • 15 years “in the trenches cubicles” • Developer of RTC (VoIP, IM, WebRTC) solutions • Often dealing with DevOps topics • Founder of RTCSoft in 2015 @giavac https://github.com/giavac gv@rtcsoft.net 2
  • 3. Docker usage scenarios • Run (micro)services • Deployment mechanism • Prototyping • Testing • Continuous Integration/Delivery 3
  • 4. What’s in a name? 4
  • 5. Previously on this show 1/2 http://www.slideshare.net/GiacomoVacca/docker-and-puppet-for-continuous-integration 5
  • 6. Previously on this show 2/2 http://www.slideshare.net/GiacomoVacca/docker-from-scratch 6
  • 7. What is Docker, really? • An Open-Source (Go) framework to manage “container virtualisation” (started in 2013) • Docker isolates multiple user spaces (file systems) inside the same host • The user space instances are called “Containers” • They give you the illusion of being inside a VM • Think about “execution environments” or “sandboxes” • No need for an hypervisor (and so very quick to launch) • Requires x64 Linux and kernel 3.8+ • Google started dev of cgroups for the Linux kernel, then together with namespaces and chroot become LXC 7
  • 8. Main Docker components • Engine: manages images and containers. Exposes an API • Client: connects to the Engine (locally or remotely) • Compose: manages multi-container architectures • Swarm: orchestrates containers on multiple hosts • Kitematic: GUI for Docker client • Machine: provision and manage VMs to host containers 8
  • 10. Virtual Machines vs Docker Source: https://www.docker.com/what-docker 10
  • 11. What Docker is not? • A programming language • An OS • A Virtual Machine • An image in the traditional hypervisor-based Virtual Machine concept 11
  • 12. Where is Docker used? • Uber, eBay, BBC News, shopify, ING, Swisscom, Groupon (1) • and many others… • Supported by Google Cloud Platform • with the Container Engine + Kubernetes (1) source: https://www.docker.com/customers 12
  • 13. Who should know about Docker? • Developers • Including mobile developers • Sysadmins • “DevOps” people • Architects/CTO/COO 13
  • 14. Basic topics • Images and Containers • Image structure • Dockerfiles • Building an image • Interacting with an image repo • Running a container 14 • Architecture • Typical Linux vs Toolbox • Volumes • Port mapping
  • 15. Some advanced topics • Inspecting/debugging containers • inspect/attach/exec/logs/top • Volumes, data containers • Multicontainer architectures • Link, network, Compose • Docker inside Docker • Is it worth it? Consider the “sibling” approach (“socket mounting”) instead. • Orchestrating Docker containers via Puppet 15
  • 16. Inspect a Container docker inspect CONTAINER_NAME Formatting options, e.g.: docker inspect --format='{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' CONTAINER_ID 16
  • 17. Output of inspect { "Id": "c61b85d3a9451d2ac3bbe301f54dc97b0df13c2835d0fb1f6214db64929e646d", "Created": "2016-01-05T09:47:16.125279193Z", "Path": "/bin/sh", "Args": [ "-c", "nginx" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 16817, … 17
  • 18. Debugging a container $ docker info $ docker attach CONTAINER_NAME $ docker exec -it CONTAINER_NAME COMMAND e.g. ‘$ docker exec -it gvacca/nginx /bin/bash’ $ docker logs CONTAINER_NAME Or show processes running inside a container: $ docker top CONTAINER_NAME 18
  • 19. Volumes • Share a folder between host and container • VOLUME commands inside the Dockerfile • Dynamic volume association at run time: one or more ‘-v’ arguments • Volumes shared by an image are available even if the container is not running (but it needs to still exist). 19
  • 20. Multicontainer architecture • Define many containers (aka “services”) • Define relationship between them (e.g. “depends on”) • Define networking • Start/Stop all services at the same time 20
  • 21. Networks of Containers • “docker network” defined since Docker 1.9 • Create a virtual network, then attach containers to it • Containers on different networks by default don’t see each other • Internal private addressing, managed by Docker • Brilliant for prototyping and emulating entire architectures 21
  • 22. Docker network • ‘docker network create NAME’ • ‘docker network attach NAME CONTAINER’ • ‘docker network ls’ • ‘docker network inspect NAME’ 22
  • 23. Docker Compose • docker-compose.yml, defines a set of containers (“services”). Written in python, available with Toolbox. • Define their runtime properties (images, volumes, ports, dependencies) • Interact with registries (public/private) • Network • Containers can be located with a name, instead of IP address (e.g ‘https:// mysql_server:3306’, from 1.6.2) • Default name is ‘APPFOLDER_default’ 23
  • 24. Compose main commands • ‘docker-compose build [service]’ • ’docker-compose [--verbose] up [-d]’ • ‘docker-compose start [service]’ • ‘docker-compose down’ • ‘docker-compose top’ 24
  • 25. Docker Machine • Provision and manage VMs • Available with Toolbox (uses Virtualbox) • ‘docker-machine active’ • ‘docker-machine ls’ • ‘docker-machine start default’ • eval $(docker-machine env) 25
  • 26. Let’s play with Docker Compose • Write your docker-compose.yml file • ’docker-compose build [service]’ • Builds the images when needed (‘build’), or exits (‘image’) • ’docker-compose up’ • Add ‘-d’ to run in background (daemon mode) • ‘docker ps’ to see the launched containers • ‘docker-compose ps’ • See the processes and other details - similar to ‘docker ps’ • ‘docker-compose down/stop/kill’ • To switch off the node 26
  • 27. The Workshop • Create a simple app with 2 containers • One with stock image • One with built image • Run and inspect • Check volumes • Create the same app with Compose • Run and inspect • Check network and volumes 27
  • 28. Compose scenario - steps Browse to http://192.168.99.100:5000/ docker-compose --verbose up Browse to http://192.168.99.100:5000/ CTRL+C docker-compose --verbose up -d docker ps | grep 'composetest' docker-compose ps docker-compose --verbose ps docker network ls |grep 'composetest' docker network inspect 'composetest_default' python inspect_docker_network.py 'composetest_default' 28
  • 29. docker ps Giacomos-MacBook-Pro:docker-experiments gv$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 13398ae967e5 gvacca/kamailio_async:ubuntu14 "tail -f /dev/null" 3 months ago Up 3 seconds 5060/tcp dockerexperiments_kamailio_async_ubuntu_1 51c8105ef7ab gvacca/kamailio_async:centos7 "tail -f /dev/null" 3 months ago Up 3 seconds 5060/tcp dockerexperiments_kamailio_async_centos_1 4e21f9fd9694 gvacca/sipp "tail -f /dev/null" 3 months ago Up 3 seconds dockerexperiments_sipp_1 381272e54d19 gvacca/nginx_ssl "/bin/sh -c nginx" 3 months ago Up 3 seconds 80/tcp, 443/tcp dockerexperiments_nginx_ssl_1 29
  • 30. docker inspect http_network [ { "Name": "http_network", "Id": "29c9951bf3fbaaa73f5a0fa39a4de1c65fbbe99f0aef8b49718a921ab6deed17", "Scope": "local", "Driver": "bridge", "IPAM": { "Driver": "default", "Config": [ {} ] }, "Containers": { "13398ae967e5ba0677cd151bda64c4458671b335dd46d67c7f4ef01b8b65821b": { "EndpointID": "18ebb70df95e24cec9932f9925c655fa9866aa34e2a8a40e90827ba3bea8441d", "MacAddress": "02:42:ac:13:00:05", "IPv4Address": "172.19.0.5/16", "IPv6Address": "" }, "381272e54d19f24c6c3f923e3f35e8676d2fd19ab229fb3a382893c889367c42": { "EndpointID": "abd412f88e83b6e8460b222f3aa293dd6f118f8d54a29403e1a68f27a22a5d43", "MacAddress": "02:42:ac:13:00:02", "IPv4Address": "172.19.0.2/16", "IPv6Address": "" }, "4e21f9fd9694a50a9ff42f0cae11ea1e208b72ec21a539014284082b5887c57f": { "EndpointID": "2a5e7d1800ddb55f7c4192d819aff413b024a2d0e97be612ca000497d23d80bf", "MacAddress": "02:42:ac:13:00:03", "IPv4Address": "172.19.0.3/16", "IPv6Address": "" }, "51c8105ef7ab8079cf05428a83ea7f6c6395a2a5fc08075617d855992a27492f": { "EndpointID": "5871de671429a51b52f8b498410d5ffe394e95ceccc8ac6d2dadf9b139727821", "MacAddress": "02:42:ac:13:00:04", "IPv4Address": "172.19.0.4/16", "IPv6Address": "" } 30
  • 31. Scripting with docker APIs $ python inspect_docker_network.py http_network 13398ae967e5ba0677cd151bda64c4458671b335dd46d67c7f4ef01b8b65821b '/dockerexperiments_kamailio_async_ubuntu_1': 172.19.0.5/16 4e21f9fd9694a50a9ff42f0cae11ea1e208b72ec21a539014284082b5887c57f '/dockerexperiments_sipp_1': 172.19.0.3/16 381272e54d19f24c6c3f923e3f35e8676d2fd19ab229fb3a382893c889367c42 '/dockerexperiments_nginx_ssl_1': 172.19.0.2/16 51c8105ef7ab8079cf05428a83ea7f6c6395a2a5fc08075617d855992a27492f '/dockerexperiments_kamailio_async_centos_1': 172.19.0.4/16 31
  • 32. inspect_docker_network.py #!/usr/bin/python # Get the output of 'docker network inspect' for a given network # and return containers names and their IP address import json import subprocess import sys network_name = sys.argv[1] network_json = subprocess.check_output(["docker", "network", "inspect", network_name]) network = json.loads(network_json) containers = network[0]['Containers'] for container_id in containers: container_name = subprocess.check_output(["docker", "inspect", "--format", "'{{ .Name }}'", container_id]) print container_id + " " + container_name.strip() + ": " + containers[container_id] ['IPv4Address'] 32
  • 33. Cleaning up • docker rm CONTAINER • docker rmi IMAGE • docker rmi $(docker images -q --filter "dangling=true") 33
  • 35. Recommended Books • “The Docker book”, J. Turnbull, http://www.amazon.co.uk/Docker-Book- Containerization-new-virtualization-ebook/dp/B00LRROTI4 • “Using Docker”, A. Mouat, O’Reilly, https://www.amazon.co.uk/Using-Docker- Adrian-Mouat/dp/1491915765 • “Continuous Delivery”, J. Humble, http://www.amazon.com/Continuous-Delivery- Deployment-Automation-Addison-Wesley/dp/0321601912 • “Building Microservices”, S. Newman, http://shop.oreilly.com/product/ 0636920033158.do • "Docker Networking and Service Discovery", O’Reilly, https://www.nginx.com/ resources/library/docker-networking/ 35
  • 36. Other useful references • https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker- for-ci/ • https://www.dajobe.org/blog/2015/04/18/making-debian-docker- images-smaller/ • http://blog.replicated.com/2016/02/05/refactoring-a-dockerfile-for- image-size/ 36