您好我通过以下方式创建了swarm集群
在我的工作站上:
$docker pull swarm
$docker run --rm swarm create
在另一个 docker 主机上
docker run -d swarm join --addr=nodeIP:2375token://cluster_id_from_step_2
回到工作站
docker run -d -p 8333:2375 swarm manage token://cluster_id
如果我通过在我的工作站上运行以下命令列出在该集群上运行的节点,我会看到 nodeIP 但是如果我运行以下命令
sudo docker -H tcp://workstationIP:8333 info
Containers: 0
Images: 0
Role: primary
Strategy: spread
Filters: affinity, health, constraint, port, dependency
Nodes: 0
CPUs: 0
Total Memory: 0 B
为什么我在节点中看不到节点 IP?
注意:此设置在基于 virtualBox 的 vagrant 的专用网络中运行
流浪文件
Vagrant.configure(2) do |config|
config.vm.box = "phusion/ubuntu-14.04-amd64"
config.vm.hostname = "docker-test-machine"
config.vm.network "private_network", type: "dhcp"
config.vm.network "forwarded_port", guest: 80, host: 80
config.ssh.forward_agent = true
config.vm.synced_folder "H:\\home_folder", "/home_folder"
config.vm.provider "virtualbox" do |vb|
vb.memory = 2048
vb.cpus = 4
end
config.vm.provision "shell", inline: <<-SCRIPT
## install docker
if ! type docker >/dev/null; then
echo "installing Docker"
curl -sL https://get.docker.io/ | sh
curl -sL https://raw.githubusercontent.com/dotcloud/docker/master/contrib/completion/bash/docker > /etc/bash_completion.d/docker
adduser vagrant docker
else
echo "upgrading Docker"
apt-get update
apt-get -y install lxc-docker
fi
SCRIPT
end