Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Last active November 11, 2017 23:42
Show Gist options
  • Save diegopacheco/6c75a445337e1ac29fd9ae07a16e2500 to your computer and use it in GitHub Desktop.
Save diegopacheco/6c75a445337e1ac29fd9ae07a16e2500 to your computer and use it in GitHub Desktop.
Multi-host Docker network Overlay in AWS

Steps

  1. Open Sg port: 2377
  2. Open any other ports your app might need
  3. Install docker
  4. Install sawrm master
  5. Join swarm workers
  6. Create overlay
  7. deploy service / containers

Node 1 - Master

# 
# Install Docker
#
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo yum install -y git
sudo yum -y groupinstall "Development Tools"
docker version
docker network ls

#
# Create Master node Swarm
#
docker swarm init
docker node ls

#
# Create Overlay
#
docker network ls
docker network create --attachable -d overlay overnet
docker network ls

#
# Deploy Service, Test, SSH
#
docker service create --name myservice --network overnet --replicas 2 alpine sleep 1d
docker service ls
docker ps
docker service ps myservice
docker network inspect overnet

docker exec -it 66491d2e91e9 sh
ping 10.0.0.3

Node 2 - worker

# 
# Install Docker
#
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo yum install -y git
sudo yum -y groupinstall "Development Tools"
docker version
docker network ls

#
# Join Master Swarm as Worker
#
docker swarm join --token SWMTKN-1-2tla28a4oxh9sit59p3v1q325eizxmrofy87p72uggddwvet7p-5vmuq7ewk9m4vtxvkv5gdvfn9 172.28.198.251:2377
docker ps
docker network ls
docker inspect 2cd88f5c369f
@diegopacheco
Copy link
Author

diegopacheco commented Nov 11, 2017

Create Docker network with Overlay

docker network create --attachable -d overlay myDockerNetDynomite

Run dynomite using docker(based on dynomite-docker)

export DV=0.5.8
docker run -d --net myDockerNetDynomite --ip 10.0.0.5 --name dynomite1 -e DYNOMITE_NODE=1 -e DYNOMITE_VERSION=$DV diegopacheco/dynomitedocker
docker run -d --net myDockerNetDynomite --ip 10.0.0.6 --name dynomite2 -e DYNOMITE_NODE=2 -e DYNOMITE_VERSION=$DV diegopacheco/dynomitedocker
docker run -d --net myDockerNetDynomite --ip 10.0.0.7 --name dynomite3 -e DYNOMITE_NODE=3 -e DYNOMITE_VERSION=$DV diegopacheco/dynomitedocker

Dynomite cluster config

redis_cluster_1.yml  
dyn_o_mite:
  datacenter: dc
  rack: rack1
  dyn_listen: 0.0.0.0:8101
  listen: 0.0.0.0:8102
  dyn_seed_provider: simple_provider
  dyn_seeds:
  - 10.0.0.6:8101:rack2:dc:100
  - 10.0.0.7:8101:rack3:dc:100
  servers:
  - 127.0.0.1:6379:1
  tokens: '100'
redis_cluster_2.yml
dyn_o_mite:
  datacenter: dc
  rack: rack2
  dyn_listen: 0.0.0.0:8101
  listen: 0.0.0.0:8102
  dyn_seed_provider: simple_provider
  dyn_seeds:
  - 10.0.0.5:8101:rack2:dc:100
  - 10.0.0.7:8101:rack3:dc:100
  servers:
  - 127.0.0.1:6379:1
  tokens: '100'
redis_cluster_3.yml 
dyn_o_mite:
  datacenter: dc
  rack: rack3
  dyn_listen: 0.0.0.0:8101
  listen: 0.0.0.0:8102
  dyn_seed_provider: simple_provider
  dyn_seeds:
  - 10.0.0.5:8101:rack2:dc:100
  - 10.0.0.6:8101:rack3:dc:100
  servers:
  - 127.0.0.1:6379:1
  tokens: '100'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment