Skip to content

waisbrot/docker-wait

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 172.17.0.105:5432  .  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=8.8.8.8:53,github.com:443 waisbrot/wait
waiting for 8.8.8.8:53  .  up!
waiting for github.com:443  .  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 TARGETS=github.com:5432 -e TIMEOUT=2 waisbrot/wait
waiting for github.com:5432  ..  ERROR: unable to connect

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

credits

The single port usage idea and dockerfile was pulled from aanand/wait: https://github.com/aanand/docker-wait

About

Wait for services in other containers to start

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%