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
25. 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
28. 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
30. Data in containers pattern
Docker host
/var/volume1
DATA
/var/volume2
/var/volume1
client1
/var/volume2
--volumes-from DATA--volumes-from DATA
31. 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
33. 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
?
34. 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?
40. 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
41. 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
44. 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
52. Port forwarding into a
container
(boot2docker) ssh -L 8000:localhost:8000
Expose a container port to the host machine
53. 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
54. 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