V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
wangxiaoaer
V2EX  ›  问与答

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

  •  
  •   wangxiaoaer · Dec 5, 2018 · 1876 views
    This topic created in 2706 days ago, the information mentioned may be changed or developed.

    按照官网说的: 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 replies    2018-12-05 21:08:40 +08:00
    wangxiaoaer
        1
    wangxiaoaer  
    OP
       Dec 5, 2018 via Android
    技术问题怎么这么人少?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2314 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 01:20 · PVG 09:20 · LAX 18:20 · JFK 21:20
    ♥ Do have faith in what you're doing.