This document provides an overview of how Docker can make developers happy by providing clean and perfect development environments, fast application mobility and repeatability, and enabling great collaboration through microservices architecture. It then discusses various workflows and techniques for using Docker, including developing inside a single running container, leveraging containers to modularize code, reusing Dockerfiles, sharing data between containers through volumes, accessing Docker in a VM through methods like NFS or Samba, using linked containers for simple service connections, and opening ports on containers using techniques like port forwarding, VBoxManage port exposure, and iptables.
10. 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
23. 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
26. 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
28. Data in containers pattern
Docker host
/var/volume1
DATA
/var/volume2
/var/volume1
client1
/var/volume2
--volumes-from DATA--volumes-from DATA
29. 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
31. 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
?
32. 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?
38. 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
39. 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
42. 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
50. Port forwarding into a
container
(boot2docker) ssh -L 8000:localhost:8000
Expose a container port to the host machine
51. 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
52. 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