Docker——容器编排(七)(3)

三、Docker Swarm


Docker——容器编排(七)(3)


Docker——容器编排(七)(3)


Docker——容器编排(七)(3)


环境准备

(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

上一篇:工厂设计模式、简单工厂设计模式、抽象工厂设计模式(1)


下一篇:Docker 分享 小 Demo示例(上)