SlideShare a Scribd company logo
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

More Related Content

PDF
Docker From Scratch
PDF
Docker
PDF
Continuous Integration and Kamailio
PDF
Docker by Example - Basics
ODP
Docker - The Linux Container
PDF
Shipping Applications to Production in Containers with Docker
PDF
From development environments to production deployments with Docker, Compose,...
PDF
The state of the swarm
Docker From Scratch
Docker
Continuous Integration and Kamailio
Docker by Example - Basics
Docker - The Linux Container
Shipping Applications to Production in Containers with Docker
From development environments to production deployments with Docker, Compose,...
The state of the swarm

What's hot (20)

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

Similar to Docker - From Walking To Running (20)

PDF
Docker in real life
PDF
Introduction to Docker at Glidewell Laboratories in Orange County
PDF
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
PDF
Docker 0.11 at MaxCDN meetup in Los Angeles
PDF
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
PDF
Agile Brown Bag - Vagrant & Docker: Introduction
PPTX
Containerization using docker and its applications
PPTX
Containerization using docker and its applications
PDF
手把手帶你學 Docker 入門篇
PDF
Docker workshop 0507 Taichung
PDF
PDF
Docker_AGH_v0.1.3
PDF
Introduction to Docker at the Azure Meet-up in New York
PDF
Introduction to Docker and deployment and Azure
PDF
Faster and Easier Software Development using Docker Platform
PDF
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
PDF
Dockercon 23 - Getting started with Docker
PDF
Docker fundamentals
PDF
An Introduction To Docker
Docker in real life
Introduction to Docker at Glidewell Laboratories in Orange County
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 0.11 at MaxCDN meetup in Los Angeles
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Agile Brown Bag - Vagrant & Docker: Introduction
Containerization using docker and its applications
Containerization using docker and its applications
手把手帶你學 Docker 入門篇
Docker workshop 0507 Taichung
Docker_AGH_v0.1.3
Introduction to Docker at the Azure Meet-up in New York
Introduction to Docker and deployment and Azure
Faster and Easier Software Development using Docker Platform
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Dockercon 23 - Getting started with Docker
Docker fundamentals
An Introduction To Docker
Ad

More from Giacomo Vacca (14)

PDF
WebRTC in SignalWire - troubleshooting media negotiation
PDF
Testing WebRTC applications at scale.pdf
PDF
GiacomoVacca - WebRTC - troubleshooting media negotiation.pdf
PDF
STUN protocol
PDF
Modern VoIP in modern infrastructures
PDF
RIPP Notes
PDF
Modern VoIP in Modern Infrastructures
PDF
An SFU/MCU integration for heterogeneous environments
PDF
Kamailio World 2018 - Workshop: kamailio-tests
PDF
Homer - Workshop at Kamailio World 2017
PDF
[workshop] The Revolutionary WebRTC
PDF
Docker and Puppet for Continuous Integration
PDF
Top 5 Challenges To Add Web Calls to Truphone VoIP Platform
PDF
Automatic Kamailio Deployments With Puppet
WebRTC in SignalWire - troubleshooting media negotiation
Testing WebRTC applications at scale.pdf
GiacomoVacca - WebRTC - troubleshooting media negotiation.pdf
STUN protocol
Modern VoIP in modern infrastructures
RIPP Notes
Modern VoIP in Modern Infrastructures
An SFU/MCU integration for heterogeneous environments
Kamailio World 2018 - Workshop: kamailio-tests
Homer - Workshop at Kamailio World 2017
[workshop] The Revolutionary WebRTC
Docker and Puppet for Continuous Integration
Top 5 Challenges To Add Web Calls to Truphone VoIP Platform
Automatic Kamailio Deployments With Puppet

Recently uploaded (20)

PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Transform Your Business with a Software ERP System
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
System and Network Administraation Chapter 3
PDF
AI in Product Development-omnex systems
PDF
Nekopoi APK 2025 free lastest update
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPT
Introduction Database Management System for Course Database
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Operating system designcfffgfgggggggvggggggggg
Odoo Companies in India – Driving Business Transformation.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
How to Choose the Right IT Partner for Your Business in Malaysia
Design an Analysis of Algorithms I-SECS-1021-03
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Understanding Forklifts - TECH EHS Solution
VVF-Customer-Presentation2025-Ver1.9.pptx
ManageIQ - Sprint 268 Review - Slide Deck
Transform Your Business with a Software ERP System
2025 Textile ERP Trends: SAP, Odoo & Oracle
System and Network Administraation Chapter 3
AI in Product Development-omnex systems
Nekopoi APK 2025 free lastest update
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Introduction Database Management System for Course Database
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Which alternative to Crystal Reports is best for small or large businesses.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Operating system designcfffgfgggggggvggggggggg

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