0

When I scale a service up from 1 node (Node A) to 2 nodes (Node A and Node B), I see traffic immediately being routed to both nodes (including the new Node B even though it isn't ready).

As a result, an Nginx proxy will return 502s half the time (until Node B is ready).

Any suggestions how you can delay this traffic?

Note: this isn't waiting for another container to come up as mentioned here: Docker Compose wait for container X before starting Y This is about delaying the network connection until the container is ready.

Snowcrash
  • 80,579
  • 89
  • 266
  • 376

1 Answers1

0

If you do not configure a healthcheck section, docker will assume that the container is available as soon as it is started.

Note that the initial healthcheck is only done after the set interval.

So you could add something extremely basic like testing if port 80 is connectable (you need nc in your docker image):

healthcheck:
  test: nc -w 1 127.0.0.1 80 < /dev/null
  interval: 30s
  timeout: 10s
  retries: 3
  start_period: 5s
marcolz
  • 2,880
  • 2
  • 23
  • 28