三、Docker Swarm
环境准备
(1)根据Vagrantfile创建3台centos机器
新建swarm-docker-centos7文件夹,创建Vagrantfile
boxes = [ { :name => "manager-node", :eth1 => "192.168.0.11", :mem => "1024", :cpu => "1" }, { :name => "worker01-node", :eth1 => "192.168.0.12", :mem => "1024", :cpu => "1" }, { :name => "worker02-node", :eth1 => "192.168.0.13", :mem => "1024", :cpu => "1" } ] Vagrant.configure(2) do |config| config.vm.box = "centos/7" boxes.each do |opts| config.vm.define opts[:name] do |config| config.vm.hostname = opts[:name] config.vm.provider "vmware_fusion" do |v| v.vmx["memsize"] = opts[:mem] v.vmx["numvcpus"] = opts[:cpu] end config.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--memory", opts[:mem]] v.customize ["modifyvm", :id, "--cpus", opts[:cpu]] v.customize ["modifyvm", :id, "--name", opts[:name]] end config.vm.network :public_network, ip: opts[:eth1] end end end
(2)进入到对应的centos里面,使得root账户能够登陆,从而使用XShell登陆
vagrant ssh manager-node/worker01-node/worker02-node sudo -i vi /etc/ssh/sshd_config 修改PasswordAuthentication yes passwd 修改密码 systemctl restart sshd
(3)在win上ping一下各个主机,看是否能ping通
ping 192.168.0.11/12/13
(4)在每台机器上安装Docker engine