Created
          October 19, 2015 21:52 
        
      - 
      
- 
        Save dave-tucker/64b6a3fa91bf5c68b326 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 -e | |
| # Docker Machine Setup | |
| docker-machine create \ | |
| -d virtualbox \ | |
| --virtualbox-boot2docker-url https://github.com/tianon/boot2docker-legacy/releases/download/v1.9.0-rc1/boot2docker.iso \ | |
| mhs-consul | |
| docker $(docker-machine config mhs-consul) run -d \ | |
| -p "8500:8500" \ | |
| -h "consul" \ | |
| progrium/consul -server -bootstrap | |
| docker-machine create \ | |
| -d virtualbox \ | |
| --virtualbox-boot2docker-url https://github.com/tianon/boot2docker-legacy/releases/download/v1.9.0-rc1/boot2docker.iso \ | |
| --swarm \ | |
| --swarm-image="swarm:1.0.0-rc1" \ | |
| --swarm-master \ | |
| --swarm-discovery="consul://$(docker-machine ip mhs-consul):8500" \ | |
| --engine-opt="cluster-store=consul://$(docker-machine ip mhs-consul):8500" \ | |
| mhs-demo0 | |
| docker-machine create \ | |
| -d virtualbox \ | |
| --virtualbox-boot2docker-url https://github.com/tianon/boot2docker-legacy/releases/download/v1.9.0-rc1/boot2docker.iso \ | |
| --swarm \ | |
| --swarm-image="swarm:1.0.0-rc1" \ | |
| --swarm-discovery="consul://$(docker-machine ip mhs-consul):8500" \ | |
| --engine-opt="cluster-store=consul://$(docker-machine ip mhs-consul):8500" \ | |
| mhs-demo1 | |
| # Workaround for https://github.com/docker/docker/issues/17047 | |
| docker-machine ssh mhs-demo0 'sudo sh -c "set -ex; /etc/init.d/docker stop || true; sed -i '\''5i --cluster-advertise='$(docker-machine ip mhs-demo0)':0\"'\'' /var/lib/boot2docker/profile; /etc/init.d/docker start"' | |
| docker-machine ssh mhs-demo1 'sudo sh -c "set -ex; /etc/init.d/docker stop || true; sed -i '\''5i --cluster-advertise='$(docker-machine ip mhs-demo1)':0\"'\'' /var/lib/boot2docker/profile; /etc/init.d/docker start"' | |
| sleep 2 | |
| # Let's point at swarm | |
| eval $(docker-machine env --swarm mhs-demo0) | |
| # Create an overlay network | |
| docker network create -d overlay my-net | |
| # Check that it's on both hosts | |
| docker network ls | |
| # Try it out! | |
| docker run -itd --name=web --net=my-net --env="constraint:node==mhs-demo0" nginx | |
| docker run -it --rm --net=my-net --env="constraint:node==mhs-demo1" busybox wget -O- http://web | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment