Public | Automated Build

Last pushed: a year ago
Short Description
Small docker wait-for-hosts-coming-up-and-listening image.
Full Description

docker-wait is a really small Docker utility that blocks until other container(s) is(are) accepting TCP connections, and errors-out if it cannot connect within a given timeout.

Possible uses are:

  • in CI environments, to ensure that containers are up before tests begin running against them
  • in a deployment pipeline, to assure the correct startup sequence (orchestrator-like)

The default operation looks up all the EXPOSE-d ports of all the linked containers and waits for them.

$ docker run -d --name nasturzo some-image-or-other
$ docker run --rm --link nasturzo netservice/docker-wait
waiting for 172.17.0.106:8080 .. up!
Everything is up and listening

It doesn't matter what the link aliases are.

If:

  • you want to wait for only a subset of the links/ports, or
  • you want to connect to hosts/ports that haven't been linked explicitly via --link, or
  • you want to check hosts are outside the containerized environment you're running inside

then you can provide a comma-delimited list of host:port targets in the TARGETS variable:

$ docker run --rm -e TARGETS=8.8.8.8:53,github.com:443 netservice/docker-wait
waiting for 8.8.8.8:53 .up!
waiting for github.com:443 . up!
Everything is up and listening

By default each connection attempt will give up after 10 seconds. You can specify a custom timeout via the TIMEOUT env variable:

$ docker run --rm -e TARGETS=github.com:5432 -e TIMEOUT=25 netservice/docker-wait
waiting for github.com:5432 ......................... ERROR: unable to connect

If any TARGET times out, the docker-wait container immediately exits with status code 1.

Usage consideration

It's a good practice IMHO to run this kind of container and delete it immediately afterwards, using --rm or remove:true. Running a docker-gc or a cleanup script regularly it's another thing.

Credits

https://github.com/ddn0/docker-wait / https://github.com/aanand/docker-wait

Docker Pull Command
Owner
netservice
Source Repository

Comments (0)