Skip to content

Instantly share code, notes, and snippets.

@lucj
Created August 31, 2017 13:25
Show Gist options
  • Save lucj/6e20db4614d8ba4266347c4d1357f5e7 to your computer and use it in GitHub Desktop.
Save lucj/6e20db4614d8ba4266347c4d1357f5e7 to your computer and use it in GitHub Desktop.
Running test app on Docker4AWS
// Creation of the network
$ docker network create --driver overlay net1
// Définition of 2 services in services.yml
version: '3.3'
services:
consul:
image: consul:0.9.2
command: agent -server -client=0.0.0.0 -bootstrap -ui -bind '{{ GetInterfaceIP "eth0" }}'
dns:
- 127.0.0.1
networks:
- net1
ports:
- "8500:8500"
db:
image: 'mongo:3.4'
networks:
- net1
volumes:
- db-data:/data/db
volumes:
db-data:
networks:
net1:
external: true
// Running the stack
$ docker stack deploy -c services.yml app
// Check network interfaces of consul's container
/# ip a
...
48: eth0@if49: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1450 qdisc noqueue state UP
link/ether 02:42:0a:ff:00:06 brd ff:ff:ff:ff:ff:ff
inet 10.255.0.6/16 scope global eth0
valid_lft forever preferred_lft forever
inet 10.255.0.5/32 scope global eth0
valid_lft forever preferred_lft forever
50: eth1@if51: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
link/ether 02:42:ac:12:00:03 brd ff:ff:ff:ff:ff:ff
inet 172.18.0.3/16 scope global eth1
valid_lft forever preferred_lft forever
53: eth2@if54: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1450 qdisc noqueue state UP
link/ether 02:42:0a:00:01:03 brd ff:ff:ff:ff:ff:ff
inet 10.0.1.3/24 scope global eth2
valid_lft forever preferred_lft forever
inet 10.0.1.2/32 scope global eth2
valid_lft forever preferred_lft forever
...
// Check network interfaces of mongo's container
/# ip a
...
49: eth0@if50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default
link/ether 02:42:0a:00:01:05 brd ff:ff:ff:ff:ff:ff
inet 10.0.1.5/24 scope global eth0
valid_lft forever preferred_lft forever
inet 10.0.1.4/32 scope global eth0
valid_lft forever preferred_lft forever
51: eth1@if52: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:12:00:03 brd ff:ff:ff:ff:ff:ff
inet 172.18.0.3/16 scope global eth1
valid_lft forever preferred_lft forever
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment