Links sometimes not working with Docker-compose version 2

Given the following (working) docker-compose.yaml file:

nsqlookupd:
  image: nsqio/nsq
  ports:
    - "4160:4160"
    - "4161:4161"
  command: /nsqlookupd

nsqd:
  image: nsqio/nsq
  ports:
    - "4150"
    - "4151"
  links:
    - nsqlookupd:nsqlookupd
  command: /nsqd --lookupd-tcp-address=nsqlookupd:4160

nsqadmin:
  image: nsqio/nsq
  ports:
    - "4171:4171"
  links:
    - nsqlookupd:nsqlookupd
  command: /nsqadmin --lookupd-http-address=nsqlookupd:4161

If I upgrade the format to version "2" (just adding the first two lines):

version: "2"
services:
  nsqlookupd:
    image: nsqio/nsq
    ports:
      - "4160:4160"
      - "4161:4161"
    command: /nsqlookupd

  nsqd:
    image: nsqio/nsq
    ports:
      - "4150"
      - "4151"
    links:
      - nsqlookupd:nsqlookupd
    command: /nsqd --lookupd-tcp-address=nsqlookupd:4160

  nsqadmin:
    image: nsqio/nsq
    ports:
      - "4171:4171"
    links:
      - nsqlookupd:nsqlookupd
    command: /nsqadmin --lookupd-http-address=nsqlookupd:4161

This no longer works, and I do not understand why. By not working, I mean that services cannot create tcp connections:

nsqd_1       | [nsqd] 2016/04/02 16:10:47.511813 LOOKUPD(nsqlookupd:4160): ERROR PING - dial tcp: i/o timeout

nsqadmin_1   | [nsqadmin] 2016/04/02 16:10:51.865724 ERROR: failed to get topics - Failed to query any nsqlookupd: Get http://nsqlookupd:4161/topics: dial tcp: i/o timeout

From related containers I can ping other services (i.e. from nsqadmin, I can ping nsqlookupd

Any idea?

+4
source share

All Articles