Last active
          October 8, 2015 15:30 
        
      - 
      
- 
        Save dave-tucker/de6340d620ed7504d6af to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| # Set Up Environment | |
| group_name="docker-networking" | |
| my_ip="$(wget -q -O- http://icanhazip.com)" | |
| # Get the AMI for your region from this list: http://cloud-images.ubuntu.com/releases/15.04/release/ | |
| export AWS_AMI="ami-8d4268fa" | |
| export AWS_DEFAULT_REGION="eu-west-1" | |
| export AWS_ACCESS_KEY_ID="#" | |
| export AWS_SECRET_ACCESS_KEY="#" | |
| export AWS_VPC_ID="vpc-69c9a10c" | |
| # Set up Security Group in AWS | |
| aws ec2 create-security-group --group-name ${group_name} --description "A Security Group for Docker Networking" | |
| ## Permit SSH, required for Docker Machine | |
| aws ec2 authorize-security-group-ingress --group-name ${group_name} --protocol tcp --port 22 --cidr ${my_ip}/32 | |
| aws ec2 authorize-security-group-ingress --group-name ${group_name} --protocol tcp --port 2376 --cidr ${my_ip}/32 | |
| ## Permit Serf ports for discovery | |
| aws ec2 authorize-security-group-ingress --group-name ${group_name} --protocol tcp --port 7946 --cidr 0.0.0.0/0 | |
| aws ec2 authorize-security-group-ingress --group-name ${group_name} --protocol udp --port 7946 --cidr 0.0.0.0/0 | |
| ## Permit Consul HTTP API | |
| aws ec2 authorize-security-group-ingress --group-name ${group_name} --protocol tcp --port 8500 --cidr 0.0.0.0/0 | |
| # Docker Machine Setup | |
| docker-machine create \ | |
| -d aws \ | |
| --aws-security-group ${group_name} \ | |
| consul | |
| docker $(docker-machine config consul) run -d \ | |
| -p "8500:8500" \ | |
| -h "consul" \ | |
| progrium/consul -server -bootstrap | |
| docker-machine create \ | |
| -d aws \ | |
| --aws-security-group ${group_name} \ | |
| --engine-opt="cluster-store=consul://$(docker-machine ip consul):8500" \ | |
| --engine-label="com.docker.network.driver.overlay.bind_interface=eth1" \ | |
| demo-0 | |
| docker-machine create \ | |
| -d aws \ | |
| --aws-security-group ${group_name} | |
| --engine-opt="cluster-store=consul://$(docker-machine ip consul):8500" \ | |
| --engine-label="com.docker.network.driver.overlay.bind_interface=eth1" \ | |
| --engine-label="com.docker.network.driver.overlay.neighbor_ip=$(docker-machine ip demo-0)" \ | |
| demo-1 | |
| docker $(docker-machine config demo-0) network create -d overlay demo | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment