SlideShare a Scribd company logo
Nicola Paolucci!
Developer Advocate / Evangelist
with!
Happier Developer
with
Be a
Nicola Paolucci
@durdn
Bio pictures: the subtle pleasure of
embarrassing yourself in front of
hundreds of people
Tools, Tips and Hacks
2
3
The plan for this session:
Notes on Workflows and Techniques
1 Why does Docker make Developers happy?
Why?
Compulsion to have
clean and perfect
environments
© www.elephantlifestyle.com
the need for speed of every
developer with an idea
Fast application mobility,
Real repeatability
Great for development
team collaboration
Building blocks for your
Micro-services Architecture
Micro-services Architecture Blueprint
@crichardson
!
!
!
!
!
Traditional Server-side
web apps
View Controller
Model
API
Gateway
!
!
!
!
!
Browser/Native App
View Controller
Model
REST
REST
REST
Product Info
Service
Recommendation
Service
Review
Service
Single entry point
Protocol translation
Client specific
APIs
Workflows & Techniques
Workflow 1: Develop inside
a single running container
Workflow 1: Develop inside
a single running container
As you would in a single VM
Container
Start a shell in container
docker run -i -t ubuntu /bin/bash
Folder from host:!
/src
Docker host
Host folder!
/path/to/code
-v /path/to/code:/src
To use a container as a full
Development Environment
phusion/baseimage
Workflow 2: Leverage
containers, modularise
Techniques: Embrace
Reusability in Dockerfiles
Techniques: Embrace
Reusability in Dockerfiles
Write general requirements early, commit
and name relevant checkpoints, leave
customisations last
add + build routine magic
Techniques:
docker add <src> <dest>
docker add <src> <dest>
The ADD instruction copies new files
from host’s <src> to container’s <dest>
docker build your image with updated code
1
2
add + build routine magic?!
Update code in local app folder (git pull?)
Distribute and profit!3
Sharing data in containers
Techniques:
Container
Folder from host:!
/app
Docker host
Host folder!
/opt/test-app
-v /opt/test-app:/app
host to containers
share folder from
host to containers
docker run -v /opt/test-app:/app 
-i -t ubuntu /bin/bash
Use the run -v (volume option) to specify
host/container folder to be synced
From
is simple
Same pattern using
Dockerfile
FROM busybox
VOLUME ["/var/volume1", "/var/volume2"]
CMD ["/bin/true"]
Common pattern: Data in containers
Docker host
/var/volume1
DATA
/var/volume2
Common pattern:
data in containers
docker run -v /var/volume1 
-v /var/volume2 
--name DATA busybox true
Switched off, named, data container which
exposes a folder
Data in containers pattern
Docker host
/var/volume1
DATA
/var/volume2
Data in containers pattern
Docker host
/var/volume1
DATA
/var/volume2
/var/volume1
client1
/var/volume2
--volumes-from DATA--volumes-from DATA
Common pattern:
data in containers
docker run -t -i -rm --volumes-from DATA 
--name client1 ubuntu bash
Then mount the data container in your
application containers
What if you use docker
in a VM?
Container
You have an extra layer
Container folder!
/src
Docker in a VM
VM folder!
/path/to/code
-v /path/to/code:/src
Host OS
Host OS folder!
/path/to/code
?
Simplest way:
Use Guest Additions
And a VM that supports shared folders.
But what if you want to keep using the
lightest weight genius of boot2docker?
boot2docker is great!
Patched boot2docker with
vboxsf support
Patched boot2docker with
vboxsf support
Pull Request #282-4 add the feature
Patched boot2docker with
vboxsf support
https://vagrantcloud.com/dduportal/boot2docker
The UNIX way:
NFS, Samba, plan9, etc.
Access via NFS
docker pull cpuguy83/nfs-server
Pull the right image, share a data folder in it,
share it with other containers AND the host
docker run -d --name nfs --privileged 
cpuguy83/nfs-server /path/to/share
Access via Samba
docker pull svendowideit/samba
And if you prefer Samba, here’s a shortcut
ready made for you
docker run svendowideit/samba data
--links: simple service
connections for docker
linked containers
Docker host
/var/volume1
postgresql
/var/volume2
client
--link postgresql:pg
can refer to
hostname pg
in commands
Sample access to linked container
docker build -t postresql .
Build the image, run it with a name, !
link in child container
docker run -rm -P --name pg postgresql
docker run -rm -t -i --link pg:pg postgresql bash
!
psql -h pg -d docker -U docker --password
Tools, Tips & Hacks
workhorse with a secret
weapon
Tiny Core Linux
workhorse with a secret
weapon
Tiny Core Aside Awesomeness!
Every time it boots, it is
brand-spanking new
Minimal nomadic X desktop
for 12MB
Customise your boot2docker/Tiny Core
Tailor the boot sequence in!
/opt/bootlocal.sh
List personal settings folders and files !
/opt/.filetool.lst
Tunnels, tunnels… and ports
Tunnels and ports
Docker in a VMHost OS
8000 8000
Container
8000 8000
-p outer:inner
?
Port forwarding into a
container
(boot2docker) ssh -L 8000:localhost:8000
Expose a container port to the host machine
Mass-expose ports with
VBoxManage
# vm must be powered off
for i in {49000..49900}; do
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";
done
To expose all 49XXX ports you can run:
Workarounds section of boot2docker docs
Open ports on live containers
with force using iptables
sudo iptables-save
http://j.mp/force-port
Note down the command to open ports of another container
One more thing…
Be a Happier Developer with Docker: Tricks of the Trade
Nicola Paolucci
@durdn
Thank you!
Nicola Paolucci
@durdn
Thank you!

More Related Content

PPTX
DockerCon Keynote Ben Golub
PDF
Docker at Djangocon 2013 | Talk by Ken Cochrane
PDF
OpenStack - Docker - Rackspace HQ
PPTX
Docker, LinuX Container
PPTX
Architecting .NET Applications for Docker and Container Based Deployments
PDF
Docker, the Future of DevOps
PPTX
Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...
ODP
Docker - The Linux Container
DockerCon Keynote Ben Golub
Docker at Djangocon 2013 | Talk by Ken Cochrane
OpenStack - Docker - Rackspace HQ
Docker, LinuX Container
Architecting .NET Applications for Docker and Container Based Deployments
Docker, the Future of DevOps
Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...
Docker - The Linux Container

What's hot (20)

PDF
Docker for developers
PDF
Docker at Spotify - Dockercon14
PDF
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
PDF
Docker worshop @Twitter - How to use your own private registry
PPTX
Docker Understanding, What is Docker? Why Docker? How do I containerize somet...
PPTX
Intro Docker october 2013
PDF
DCA. certificate slide Session 1
PDF
Docker 101 @KACST Saudi HPC 2016
PDF
Building Reusable Development Environments with Docker
PPTX
Docker-Hanoi @DKT , Presentation about Docker Ecosystem
PDF
Docker workshop
PPTX
Docker 101 Checonf 2016
PDF
Docker by Example - Basics
PDF
docker installation and basics
PDF
Docker Registry + Basic Auth
PDF
DCA. certificate slide Session 2
PPTX
Docker - 15 great Tutorials
PDF
Shipping Applications to Production in Containers with Docker
PDF
Docker on Google App Engine
PDF
DockerCon SF 2015: Keynote Day 1
Docker for developers
Docker at Spotify - Dockercon14
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker worshop @Twitter - How to use your own private registry
Docker Understanding, What is Docker? Why Docker? How do I containerize somet...
Intro Docker october 2013
DCA. certificate slide Session 1
Docker 101 @KACST Saudi HPC 2016
Building Reusable Development Environments with Docker
Docker-Hanoi @DKT , Presentation about Docker Ecosystem
Docker workshop
Docker 101 Checonf 2016
Docker by Example - Basics
docker installation and basics
Docker Registry + Basic Auth
DCA. certificate slide Session 2
Docker - 15 great Tutorials
Shipping Applications to Production in Containers with Docker
Docker on Google App Engine
DockerCon SF 2015: Keynote Day 1
Ad

Viewers also liked (20)

PPTX
A Guide to Hiring for your Startup
PDF
DockerCon SF 2015: Docker After Launching 1 Billion Containers
PPTX
Dockerizing WordPress
PPTX
Immutable Infrastructure with Docker and EC2
PPTX
Dockerfile Basics Workshop #1
PPTX
DockerCon 16 - Moby's Cool Hack Session
PDF
DockerCon SF 2015: Maintaining the Official Node.js Docker Image
PPTX
Docker at RelateIQ
PDF
Docker Online Meetup #3: Docker in Production
PPTX
DockerCon14 John Engates
PPTX
Open source is good for both business and humanity
PDF
LXC Docker and the Future of Software Delivery
PDF
Introduction to Docker and Containers
PDF
Mobycraft:Docker in 8-bit (Meetup at Docker HQ 4/7)
PDF
Authentication and Policy Enforcement for Docker
PPTX
Intro to Docker October 2013
PDF
Understanding Containers through Gaming by Brendan Fosberry
PPTX
Docker at DevTable
PPTX
20 mins to Faking the DevOps Unicorn by Matt williams, Datadog
PPTX
DockerCon EU 2015: From Local Development to Production Deployments using Ama...
A Guide to Hiring for your Startup
DockerCon SF 2015: Docker After Launching 1 Billion Containers
Dockerizing WordPress
Immutable Infrastructure with Docker and EC2
Dockerfile Basics Workshop #1
DockerCon 16 - Moby's Cool Hack Session
DockerCon SF 2015: Maintaining the Official Node.js Docker Image
Docker at RelateIQ
Docker Online Meetup #3: Docker in Production
DockerCon14 John Engates
Open source is good for both business and humanity
LXC Docker and the Future of Software Delivery
Introduction to Docker and Containers
Mobycraft:Docker in 8-bit (Meetup at Docker HQ 4/7)
Authentication and Policy Enforcement for Docker
Intro to Docker October 2013
Understanding Containers through Gaming by Brendan Fosberry
Docker at DevTable
20 mins to Faking the DevOps Unicorn by Matt williams, Datadog
DockerCon EU 2015: From Local Development to Production Deployments using Ama...
Ad

Similar to Be a Happier Developer with Docker: Tricks of the Trade (20)

PDF
Docker: A New Way to Turbocharging Your Apps Development
PDF
Docker for developers on mac and windows
PPTX
Real World Experience of Running Docker in Development and Production
PDF
時代在變 Docker 要會:台北 Docker 一日入門篇
PDF
手把手帶你學Docker 03042017
PDF
BBL Premiers pas avec Docker
PPTX
Docker @ FOSS4G 2016, Bonn
PDF
手把手帶你學 Docker 入門篇
PDF
Docker workshop 0507 Taichung
PPTX
[Codelab 2017] Docker 기초 및 활용 방안
PDF
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
PDF
codemotion-docker-2014
PDF
Before & After Docker Init
PDF
Docker for Developers
PPTX
Dockerizing a Symfony2 application
PDF
DCEU 18: Developing with Docker Containers
PDF
Docker and the Container Revolution
PDF
Docker Essentials Workshop— Innovation Labs July 2020
PDF
Containerizing Web Application with Docker
PPTX
Running Docker in Development & Production (DevSum 2015)
Docker: A New Way to Turbocharging Your Apps Development
Docker for developers on mac and windows
Real World Experience of Running Docker in Development and Production
時代在變 Docker 要會:台北 Docker 一日入門篇
手把手帶你學Docker 03042017
BBL Premiers pas avec Docker
Docker @ FOSS4G 2016, Bonn
手把手帶你學 Docker 入門篇
Docker workshop 0507 Taichung
[Codelab 2017] Docker 기초 및 활용 방안
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
codemotion-docker-2014
Before & After Docker Init
Docker for Developers
Dockerizing a Symfony2 application
DCEU 18: Developing with Docker Containers
Docker and the Container Revolution
Docker Essentials Workshop— Innovation Labs July 2020
Containerizing Web Application with Docker
Running Docker in Development & Production (DevSum 2015)

More from Docker, Inc. (20)

PDF
Containerize Your Game Server for the Best Multiplayer Experience
PDF
How to Improve Your Image Builds Using Advance Docker Build
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
Securing Your Containerized Applications with NGINX
PDF
How To Build and Run Node Apps with Docker and Compose
PDF
Hands-on Helm
PDF
Distributed Deep Learning with Docker at Salesforce
PDF
The First 10M Pulls: Building The Official Curl Image for Docker Hub
PDF
Monitoring in a Microservices World
PDF
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
PDF
Predicting Space Weather with Docker
PDF
Become a Docker Power User With Microsoft Visual Studio Code
PDF
How to Use Mirroring and Caching to Optimize your Container Registry
PDF
Monolithic to Microservices + Docker = SDLC on Steroids!
PDF
Kubernetes at Datadog Scale
PDF
Labels, Labels, Labels
PDF
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
PDF
Developing with Docker for the Arm Architecture
Containerize Your Game Server for the Best Multiplayer Experience
How to Improve Your Image Builds Using Advance Docker Build
Build & Deploy Multi-Container Applications to AWS
Securing Your Containerized Applications with NGINX
How To Build and Run Node Apps with Docker and Compose
Hands-on Helm
Distributed Deep Learning with Docker at Salesforce
The First 10M Pulls: Building The Official Curl Image for Docker Hub
Monitoring in a Microservices World
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
Predicting Space Weather with Docker
Become a Docker Power User With Microsoft Visual Studio Code
How to Use Mirroring and Caching to Optimize your Container Registry
Monolithic to Microservices + Docker = SDLC on Steroids!
Kubernetes at Datadog Scale
Labels, Labels, Labels
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Build & Deploy Multi-Container Applications to AWS
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
Developing with Docker for the Arm Architecture

Be a Happier Developer with Docker: Tricks of the Trade