Skip to content

Instantly share code, notes, and snippets.

@botchagalupe
Last active August 29, 2015 14:23
Show Gist options
  • Save botchagalupe/3999b740bb9235ab7722 to your computer and use it in GitHub Desktop.
Save botchagalupe/3999b740bb9235ab7722 to your computer and use it in GitHub Desktop.
Getting Started with LIbnetwork

Getting Started with Libnetwork

Install

# Install Docker and Consul on both hosts
 
sudo apt-get install -y unzip wget curl

wget -qO- https://experimental.docker.com/ | sh

cd /usr/bin
sudo wget https://dl.bintray.com/mitchellh/consul/0.5.2_linux_amd64.zip
sudo unzip *.zip
sudo rm *.zip

docker -v 
consul --version


# On host 1

ip a    (get the ip address)

consul agent -server -bootstrap -data-dir /tmp/consul -bind=10.254.101.21 &

sudo /usr/bin/docker -d --kv-store=consul:localhost:8500 --label=com.docker.network.driver.overlay.bind_interface=eth1

# Ohost 2

ip a    (get the ip address)

consul agent -data-dir /tmp/consul -bind=10.254.101.22 &

consul join 10.254.101.21

sudo /usr/bin/docker -d --kv-store=consul:localhost:8500 --label=com.docker.network.driver.overlay.bind_interface=eth1 --label=com.docker.network.driver.overlay.neighbor_ip=10.254.101.21

On Machine 1

docker network create -d overlay prod 

docker network ls

docker network info prod

docker service publish db1.prod

cid=$(docker run -itd ubuntu)

docker service attach $cid db1.prod

On Machine 2

docker network ls

docker network info prod

docker service publish db2.prod

cid=$(docker run -itd ubuntu)

docker service attach $cid db2.prod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment