Created
          October 19, 2015 20:33 
        
      - 
      
- 
        Save dave-tucker/da67df7751b0b0ee117c 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 \ | |
| mh-consul | |
| docker $(docker-machine config mh-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 \ | |
| --engine-opt="cluster-store=consul://$(docker-machine ip mh-consul):8500" \ | |
| mh-demo0 | |
| docker-machine create \ | |
| -d virtualbox \ | |
| --virtualbox-boot2docker-url https://github.com/tianon/boot2docker-legacy/releases/download/v1.9.0-rc1/boot2docker.iso \ | |
| --engine-opt="cluster-store=consul://$(docker-machine ip mh-consul):8500" \ | |
| mh-demo1 | |
| # Workaround for https://github.com/docker/docker/issues/17047 | |
| docker-machine ssh mh-demo0 'sudo sh -c "set -ex; /etc/init.d/docker stop || true; sed -i '\''5i --cluster-advertise='$(docker-machine ip mh-demo0)':0\"'\'' /var/lib/boot2docker/profile; /etc/init.d/docker start"' | |
| docker-machine ssh mh-demo1 'sudo sh -c "set -ex; /etc/init.d/docker stop || true; sed -i '\''5i --cluster-advertise='$(docker-machine ip mh-demo1)':0\"'\'' /var/lib/boot2docker/profile; /etc/init.d/docker start"' | |
| # Create an overlay network | |
| docker $(docker-machine config mh-demo0) network create -d overlay my-net | |
| # It's on both hosts! | |
| docker $(docker-machine config mh-demo0) network ls | |
| docker $(docker-machine config mh-demo1) network ls | |
| # Let's try it out | |
| docker $(docker-machine config mh-demo0) run -itd --net=my-net --name=web nginx | |
| docker $(docker-machine config mh-demo1) run -it --rm --net=my-net busybox wget -O- http://web | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment