diff --git a/experimental/compose_swarm_networking.md b/experimental/compose_swarm_networking.md index e3dcf6ccba..570f0be7f9 100644 --- a/experimental/compose_swarm_networking.md +++ b/experimental/compose_swarm_networking.md @@ -25,32 +25,86 @@ You’ll also need a [Docker Hub](https://hub.docker.com/account/signup/) accoun Set the `DIGITALOCEAN_ACCESS_TOKEN` environment variable to a valid Digital Ocean API token, which you can generate in the [API panel](https://cloud.digitalocean.com/settings/applications). - DIGITALOCEAN_ACCESS_TOKEN=abc12345 + export DIGITALOCEAN_ACCESS_TOKEN=abc12345 Start a consul server: - docker-machine create -d digitalocean --engine-install-url https://experimental.docker.com consul - docker $(docker-machine config consul) run -d -p 8500:8500 -h consul progrium/consul -server -bootstrap + docker-machine --debug create \ + -d digitalocean \ + --engine-install-url="https://experimental.docker.com" \ + consul + + docker $(docker-machine config consul) run -d \ + -p "8500:8500" \ + -h "consul" \ + progrium/consul -server -bootstrap (In a real world setting you’d set up a distributed consul, but that’s beyond the scope of this guide!) Create a Swarm token: - SWARM_TOKEN=$(docker run swarm create) + export SWARM_TOKEN=$(docker run swarm create) -Create a Swarm master: +Next, you create a Swarm master with Machine: - docker-machine create -d digitalocean --swarm --swarm-master --swarm-discovery=token://$SWARM_TOKEN --engine-install-url="https://experimental.docker.com" --digitalocean-image "ubuntu-14-10-x64" --engine-opt=default-network=overlay:multihost --engine-label=com.docker.network.driver.overlay.bind_interface=eth0 --engine-opt=kv-store=consul:$(docker-machine ip consul):8500 swarm-0 + docker-machine --debug create \ + -d digitalocean \ + --digitalocean-image="ubuntu-14-10-x64" \ + --engine-install-url="https://experimental.docker.com" \ + --engine-opt="default-network=overlay:multihost" \ + --engine-opt="kv-store=consul:$(docker-machine ip consul):8500" \ + --engine-label="com.docker.network.driver.overlay.bind_interface=eth0" \ + swarm-0 + +Usually Machine can create Swarms for you, but it doesn't yet fully support multi-host networks yet, so you'll have to start up the Swarm manually: + + docker $(docker-machine config swarm-0) run -d \ + --restart="always" \ + --net="bridge" \ + swarm:latest join \ + --addr "$(docker-machine ip swarm-0):2376" \ + "token://$SWARM_TOKEN" + + docker $(docker-machine config swarm-0) run -d \ + --restart="always" \ + --net="bridge" \ + -p "3376:3376" \ + -v "/etc/docker:/etc/docker" \ + swarm:latest manage \ + --tlsverify \ + --tlscacert="/etc/docker/ca.pem" \ + --tlscert="/etc/docker/server.pem" \ + --tlskey="/etc/docker/server-key.pem" \ + -H "tcp://0.0.0.0:3376" \ + --strategy spread \ + "token://$SWARM_TOKEN" Create a Swarm node: - docker-machine create -d digitalocean --swarm --swarm-discovery=token://$SWARM_TOKEN --engine-install-url="https://experimental.docker.com" --digitalocean-image "ubuntu-14-10-x64" --engine-opt=default-network=overlay:multihost --engine-label=com.docker.network.driver.overlay.bind_interface=eth0 --engine-opt=kv-store=consul:$(docker-machine ip consul):8500 --engine-label com.docker.network.driver.overlay.neighbor_ip=$(docker-machine ip swarm-0) swarm-1 + docker-machine --debug create \ + -d digitalocean \ + --digitalocean-image="ubuntu-14-10-x64" \ + --engine-install-url="https://experimental.docker.com" \ + --engine-opt="default-network=overlay:multihost" \ + --engine-opt="kv-store=consul:$(docker-machine ip consul):8500" \ + --engine-label="com.docker.network.driver.overlay.bind_interface=eth0" \ + --engine-label="com.docker.network.driver.overlay.neighbor_ip=$(docker-machine ip swarm-0)" \ + swarm-1 + + docker $(docker-machine config swarm-1) run -d \ + --restart="always" \ + --net="bridge" \ + swarm:latest join \ + --addr "$(docker-machine ip swarm-1):2376" \ + "token://$SWARM_TOKEN" You can create more Swarm nodes if you want - it’s best to give them sensible names (swarm-2, swarm-3, etc). Finally, point Docker at your swarm: - eval "$(docker-machine env --swarm swarm-0)" + export DOCKER_HOST=tcp://"$(docker-machine ip swarm-0):3376" + export DOCKER_TLS_VERIFY=1 + export DOCKER_CERT_PATH="$HOME/.docker/machine/machines/swarm-0" ## Run containers and get them communicating