V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
wangxiaoaer
V2EX  ›  问与答

docker-compose 中 scale 的时候 host 解析问题

  •  
  •   wangxiaoaer · 2018-12-05 16:26:20 +08:00 · 1543 次点击
    这是一个创建于 2029 天前的主题,其中的信息可能已经有所发展或是发生改变。

    按照官网说的: https://docs.docker.com/compose/networking/ compose 启动后,会根据不同的 service 名称进行 dns 解析,比如以下的文件

    docker-compose.yaml:

    version: "3"
    services:
      website:
        image: xx
        links:
          - redis
        environment:
          - redis_url=redis://redis
          - search_url=http://search
        depends_on:
          - redis
          - vserver
    
      search:
        image: yy
    
      redis:
        image: redis
    
      proxy:
        image: jwilder/nginx-proxy
        ports:
          - 80:80
        volumes:
          - /var/run/docker.sock:/tmp/docker.sock:ro
         
    

    运行下面命令没有问题,“ http://search ”会在运行期间解析到 search 这个 container 的 ip:

    docker-compose up
    

    但是如果考虑到 scale:

    docker-compose up --scale website=2 --scale search=5
    

    那么当 website 运行的时候,“ http://search ”会解析到 5 个 search container 的哪一个呢?

    1 条回复    2018-12-05 21:08:40 +08:00
    wangxiaoaer
        1
    wangxiaoaer  
    OP
       2018-12-05 21:08:40 +08:00 via Android
    技术问题怎么这么人少?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5116 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 07:50 · PVG 15:50 · LAX 00:50 · JFK 03:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.