8. Ubuntu 14.04
eth0: 45.79.82.5
docker0: 172.17.42.1
veth7b4d22b
port 32768
start a container,
and publish a port
$ docker run -d -P …
eth0: 172.17.0.1
port: 5000
10. Ubuntu 14.04
If we want containers to
communicate with each other
eth0: 45.79.82.5
docker0: 172.17.42.1
11. Ubuntu 14.04
eth0: 45.79.82.5
docker0: 172.17.42.1
veth7b4d22b
start a container,
with a name
$ docker run -d —name web …
eth0: 172.17.0.1
port: 5000
name: web
12. Ubuntu 14.04
start containers with names,
and ‘link’ them together
eth0: 172.17.0.1
port: 5432
name: db
eth0: 172.17.0.2
port: 5000
name: web
eth0: 45.79.82.5
docker0: 172.17.42.1
veth8a5c43a
veth7b4d22b
port 32768
$ docker run -d --name db …
$ docker run -d -P --name web --link db:db …
13. Ubuntu 14.04
eth0: 172.17.0.1
port: 5432
name: db
eth0: 172.17.0.2
port: 5000
name: web
DB_PORT=tcp://172.17.0.7:5432
DB_PORT_5432_TCP=tcp://172.17.0.7:5432
DB_PORT_5432_TCP_ADDR=172.17.0.7
DB_PORT_5432_TCP_PORT=5432
DB_PORT_5432_TCP_PROTO=tcp
DB_NAME=/web/db
linking is via environment variables
custom application code needed
15. eth0: 172.17.0.1
port: 5432
name: db
h2
eth0: 45.79.90.4
docker0: 172.17.42.1
port 32768
eth0: 172.17.0.1
port: 5000
name: web
h1
eth0: 45.79.82.5
docker0: 172.17.42.1
port 32893
there’s no linking across the network
h1$ docker run -d -P —name web …
h2$ docker run -d -P —name db …
16. Container Networking
Docker
IP Allocation Subnet per Host
Routing NAT
Ports
IPTables, Port Forwarding,
Random Ports
Service Discovery Environment Variables
Multi Host Not Supported
31. and they can find each other with
regular DNS lookups
name: weave
port: 6783
name: weavedns
port: 53
eth0: 10.2.1.1
port: 5000
name: web
fqdn: web.weave.local
eth0: 10.2.1.2
port: 5432
name: db
fqdn: db.weave.local
eth0: 45.79.82.5
weave
vethwepl8289
vethwepl8801
vethwepl8709
Where’s db?
Where’s web?
32. and communicate with each other over
regular IP based protocols
name: weave
port: 6783
name: weavedns
port: 53
eth0: 10.2.1.1
port: 5000
name: web
fqdn: web.weave.local
eth0: 10.2.1.2
port: 5432
name: db
fqdn: db.weave.local
eth0: 45.79.82.5
weave
vethwepl8289
vethwepl8801
vethwepl8709
33. h2
eth0: 45.79.90.4
h1
eth0: 45.79.82.5
eth0: 10.0.0.2
name: weave
port: 6783
peer: 45.79.82.5
name: weavedns
port: 53
eth0: 10.0.0.1
name: weave
port: 6783
peer: 45.79.90.4
name: weavedns
port: 53
h1$ weave launch 10.0.0.1/16
h2$ weave launch 10.0.0.2/16 45.79.82.5
If we want containers,
on different hosts,
to communicate with each other
34. h2
eth0: 45.79.90.4
h1
eth0: 45.79.82.5
name: weavedns
port: 53
name: weavedns
port: 53
eth0: 10.2.1.1
port: 5000
name: web
fqdn: web.weave.local
eth0: 10.2.1.2
port: 5432
name: db
fqdn: db.weave.local
h1$ weave run 10.2.1.1/24 -d —name web -p 5000:5000 …
h2$ weave run 10.2.1.2/24 -d —name db …
It’s just the same,
containers can find each other with DNS
eth0: 10.0.0.2
name: weave
port: 6783
peer: 45.79.82.5
eth0: 10.0.0.1
name: weave
port: 6783
peer: 45.79.90.4
Where’s
db?
Where’s
web?
35. h2
eth0: 45.79.90.4
h1
eth0: 45.79.82.5
name: weavedns
port: 53
name: weavedns
port: 53
eth0: 10.2.1.1
port: 5000
name: web
fqdn: web.weave.local
eth0: 10.2.1.2
port: 5432
name: db
fqdn: db.weave.local
and can communicate over regular
IP based protocols
eth0: 10.0.0.2
name: weave
port: 6783
peer: 45.79.82.5
eth0: 10.0.0.1
name: weave
port: 6783
peer: 45.79.90.4
36. Container Networking
Docker Weave
IP Allocation Subnet per Host Subnet per App
Routing NAT L2 Routing
Ports IPTables As they should be
Service
Discovery
Environment Variables DNS
Multi Host Not Supported Supported