#On Local Machine Side
##Install Docker Engine && Docker Machine
###Docker Engine
sudo wget -qO- http://get.docker.com/ | sh
###Docker Machine
Docker Machine Github
wget https://github.com/docker/machine/releases/download/v0.8.0/docker-machine-`uname -s`-`uname -m` && \
sudo mv docker-machine-`uname -s`-`uname -m` /usr/local/bin/docker-machine && \
sudo chmod +x /usr/local/bin/docker-machine
##Use Docker Machine to create VM ###For Azure
- 如何取得 Subscription ID
On Linux/Mac, or Windows,上傳 Cert 到 Azure Portal,取得 Subscription ID。
- 建立 Azure VM
docker-machine create -d azure --azure-subscription-id="XXX" --azure-location="eastasia" docker-00-node01
docker-machine create -d azure --azure-subscription-id="XXX" --azure-location="eastasia" --engine-install-url https://test.docker.com docker-00-node02
docker-machine create -d azure --azure-subscription-id="XXX" --azure-location="eastasia" --azure-image canonical:ubuntuserver:16.04.0-LTS:16.04.201608150 --azure-size Standard_A1 --engine-install-url https://get.docker.com docker-00-node01
docker-machine ssh docker-00-node01 sudo usermod -aG docker docker-user
參考文件:
###For VMware
docker-machine create node-01 --driver vmwarevsphere --vmwarevsphere-datacenter ha-datacenter --vmwarevsphere-vcenter 192.168.2.12 --vmwarevsphere-username root --vmwarevsphere-password PASSWORD --vmwarevsphere-datastore 1TB --vmwarevsphere-network "VM Network"
Azure Docs
##Create a swarm cluster Old style: Get started with multi-host networking
New style: Swarm Docs, Swarm Tutorial
###First Manager
docker swarm init --advertise-addr eth0:2377 --listen-addr 0.0.0.0:2377
To add a worker to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-3xv0lszxmfary0gob9juhrvjrw1kgnau3qcee2tmdqdepc28vb-4qaycizk63r1sdgv61r72mxyu \
192.168.0.4:2377
To add a manager to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-3xv0lszxmfary0gob9juhrvjrw1kgnau3qcee2tmdqdepc28vb-8ezacy1qzubgllmne9h1zovso \
192.168.0.4:2377
###Second Manager
docker swarm join --token $TOKEN_MASTER_STRING $MASTER1:2377 --listen-addr 0.0.0.0:2377
提醒最好要有三個 Manager
###First Worker
docker swarm join --token $TOKEN_WORKER_STRING $MASTER1:2377
###Second Worker
docker swarm join --token $TOKEN_WORKER_STRING $MASTER2:2377
docker daemon \
--dns 8.8.8.8 \
--dns 8.8.4.4 \
-H unix:///var/run/docker.sock \
--label com.example.environment="production" \
--label com.example.storage="ssd"