• Docker:跨主机容器间通信之overlay [十五]


    一、配置overlay类型网络准备工作

    1、在luoahong3主机上

    docker run -d -p 8500:8500 -h consul --name consul progrium/consul -server -bootstrap
    
    [root@luoahong3 ~]# docker run -d -p 8500:8500 -h consul --name consul progrium/consul -server -bootstrap
    Unable to find image 'progrium/consul:latest' locally
    
    latest: Pulling from progrium/consul
    c862d82a67a2: Pull complete 
    0e7f3c08384e: Pull complete 
    0e221e32327a: Pull complete 
    09a952464e47: Pull complete 
    60a1b927414d: Pull complete 
    4c9f46b5ccce: Pull complete 
    417d86672aa4: Pull complete 
    b0d47ad24447: Pull complete 
    fd5300bd53f0: Pull complete 
    a3ed95caeb02: Pull complete 
    d023b445076e: Pull complete 
    ba8851f89e33: Pull complete 
    5d1cefca2a28: Pull complete 
    Digest: sha256:8cc8023462905929df9a79ff67ee435a36848ce7a10f18d6d0faba9306b97274
    Status: Downloaded newer image for progrium/consul:latest
    485d84362a1d7b3e3c0df34451cb8d228abd1f15487a9ec94dc6c6c9f93d60b5
    [root@luoahong3 ~]# docker ps -a
    CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                                                                            NAMES
    485d84362a1d        progrium/consul     "/bin/start -server …"   About a minute ago   Up About a minute   53/tcp, 53/udp, 8300-8302/tcp, 8400/tcp, 8301-8302/udp, 0.0.0.0:8500->8500/tcp   consul
    

    2、在luoahong主机上

    vim  /etc/docker/daemon.json
    {
      "hosts":["tcp://0.0.0.0:2376","unix:///var/run/docker.sock"],
      "cluster-store": "consul://192.168.231.138:8500",
      "cluster-advertise": "192.168.231.136:2376",
      "insecure-registries": ["192.168.231.136:5000"]
    }
    
     systemctl restart docker
    

     可能会报错解决方案如下

    vim /usr/lib/systemd/system/docker.service
    ExecStart=/usr/bin/dockerd 
    systemctl daemon-reload
    systemctl restart docker
    

    3、在luoahong1主机上  

    vim  /etc/docker/daemon.json
    {
      "hosts":["tcp://0.0.0.0:2376","unix:///var/run/docker.sock"],
      "cluster-store": "consul://192.168.231.138:8500",
      "cluster-advertise": "192.168.231.137:2376",
      "insecure-registries": ["192.168.231.136:5000"]
    }
    
     systemctl restart docker
    

     可能会报错解决方案如下

    vim /usr/lib/systemd/system/docker.service
    ExecStart=/usr/bin/dockerd 
    systemctl daemon-reload
    systemctl restart docker

    4、测试截图

    一、创建网络启动容器

    1、创建overlay网络

    docker network create -d overlay ol3

    2、启动容器测试

    docker run -it --network ol3 --name oldboy02 busybox:latest /bin/sh
    

    3、测试截图

    三、overlay类型网络原理图

  • 相关阅读:
    超过经理收入的员工
    搜索插入位置
    整数反转
    俩数之和
    tar 命令参数解释
    【记录】Transaction rolled back because it has been marked as rollback-only
    【转载】BIO、NIO、AIO
    【转载】JDK自带的log工具
    【转载】java8中的Calendar日期对象(LocalDateTime)
    【对象属性复制】BeanUtils.copyProperties(obj1, obj2);
  • 原文地址:https://www.cnblogs.com/luoahong/p/10289230.html
Copyright © 2020-2023  润新知