sh 与领事的Docker机器Docker Swarm
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 与领事的Docker机器Docker Swarm相关的知识,希望对你有一定的参考价值。
#!/bin/bash
# Script to generate Swarm cluster using VMware fusion:
# - consul-machine, consul for service discovery
# - swarm-master
# - swarm-node-01
# - swarm-node-02
# Note:
# This script can be easily modified for Virtualbox. typically this involves changing the driver and entering the correct ethernet adapter name. e.g.
# -d virtualbox
# --engine-opt="cluster-advertise=eth1:2376" \
# Reference
# 1. [Get started with multi-host networking](http://docs.docker.com/engine/userguide/networking/get-started-overlay/)
# 2. [Docker Machine and VMware vSphere](https://gist.github.com/philipz/2eb126f6c68568a1ef57)
# 3. [Docker Machine and Oracle virtualbox](https://docs.docker.com/machine/drivers/virtualbox/)
# 4. [Docker Machine and Oracle virtualbox](https://docs.docker.com/machine/drivers/vm-fusion/)
# Docker Machine for Consul
docker-machine \
create \
-d vmwarefusion \
consul-machine
# Start Consul
docker $(docker-machine config consul-machine) run -d --restart=always \
-p "8500:8500" \
-h "consul" \
progrium/consul -server -bootstrap
# Docker Swarm master
docker-machine \
create \
--driver vmwarefusion \
--swarm \
--swarm-master \
--swarm-discovery="consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-advertise=eth0:2376" \
swarm-master
# Docker Swarm node-01
docker-machine \
create \
-d vmwarefusion \
--swarm \
--swarm-discovery="consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-advertise=eth0:2376" \
swarm-node-01
# Docker Swarm node-02
docker-machine \
create \
-d vmwarefusion \
--swarm \
--swarm-discovery="consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-advertise=eth0:2376" \
swarm-node-02
# list docker-machine instances
docker-machine ls
# Configure to use Docker Swarm cluster
# Point your Docker environment to the machine running the swarm master
eval "$(docker-machine env --swarm swarm-master)"
docker info
以上是关于sh 与领事的Docker机器Docker Swarm的主要内容,如果未能解决你的问题,请参考以下文章
sh ?为docker-machine中的所有机器调用Docker Remote API
sh Docker附加组件机器和组合
基于docker环境搭建redis-cluster集群(多台机器)
Java Spring 在作为 Docker 容器运行时不会与 Consul 对话
sh Machine Diskutil用于在Virtualbox上运行的docker机器内安装/卸载外部卷
sh Machine Diskutil用于在Virtualbox上运行的docker机器内安装/卸载外部卷