Public | Automated Build

Last pushed: 2 years ago
Short Description
Wait for servers in other Docker containers to start
Full Description

wait is a really small Docker utility that blocks until another container is accepting TCP connections, and errors-out if it cannot connect within a given timeout. I use this
in CI environments to ensure that server containers are up before tests begin running
against them.

The default operation looks up all the EXPOSEd ports of all the linked containers
and waits for them

$ docker run -d --name mycontainer some-image-or-other
$ docker run --link mycontainer:mycontainer waisbrot/wait
waiting for  .  up!
Everything is up

It doesn't matter what the link alias is.

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 by Docker, you can provide the list in
the TARGETS variable:

$ docker run -e TARGETS=, waisbrot/wait
waiting for  .  up!
waiting for  .  up!
Everything is up

By default each connection attempt will bail after 30 seconds. You can specify how long to wait (in seconds) using the TIMEOUT env variable:

$ docker run -e -e TIMEOUT=2 waisbrot/wait
waiting for  ..  ERROR: unable to connect

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


The single port usage idea and dockerfile was pulled from aanand/wait:

Docker Pull Command
Source Repository