zoukankan      html  css  js  c++  java
  • 实现Docker跨主机间的容器网络联通

    Server1(Server) 192.168.81.58 内核版本 3.10.0-123.el7.x86_64 Docker版本 1.12.6
    Server2(Agent)  192.168.81.59             3.10.0-123.el7.x86_64                  1.12.6

    实验目标:两个CentOS7容器server1,server2网络互通
    上传docker_consul包 consul_0.7.2_linux_amd64.zip

    解压consul并移动到$PATH中
    unzip consul_0.7.2_linux_amd64.zip -d /usr/local/bin

    Server1:
    mkdir /opt/d_c
    nohup consul agent -server -bootstrap -data-dir /opt/d_c -bind=192.168.81.58 &
    显示结果:nohup: ignoring input and appending output to ‘nohup.out’

    Server2:
    mkdir /opt/d_c
    nohup consul agent -data-dir /opt/d_c -bind=192.168.81.59 &
    显示结果:nohup: ignoring input and appending output to ‘nohup.out’
    让agent加入到server中
    consul join 192.168.81.58
    显示结果:Successfully joined cluster by contacting 1 nodes.

    vim /etc/sysconfig/docker-network
    DOCKER_NETWORK_OPTIONS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store consul://localhost:8500 --cluster-advertise eno16777736:2375"
    service docker restart
    docker network ls
    显示结果包含:multihost overlay global

    查看Docker网络内的成员
    consul members list

    Server1:
    docker run -d --net=multihost --name=web1 nginx
    docker exec -it web1 /bin/bash
    Server2:
    docker run -d --net=multihost --name=web2 nginx
    docker exec -it web2 /bin/bash

    ping web1
    ping web2

    创建指定静态IP的network
    docker network create -d overlay --ip-range=192.168.2.0/24 --gateway=192.168.2.1 --subnet=192.168.2.0/24 multihost2

  • 相关阅读:
    取模 分数取模 快速幂 费马小定理
    “科林明伦杯”哈尔滨理工大学第十届程序设计竞赛 部份签到题
    shell 脚本
    pyhcl语法
    数据库实验1 SQL
    杂七杂八 Ubuntu Linux
    Kattis, Kattis 的一些问题题解
    Meow Factor 【暴力】
    解决 Eclipse 项目有红感叹号的方法
    RuntimeException与CheckedException
  • 原文地址:https://www.cnblogs.com/zhangzeyu/p/6549002.html
Copyright © 2011-2022 走看看