Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
page title tags date
Ready-Wait For Docker Containers
docker
2015-11-24

Docker supports linking together containers and will ensure that containers only start if the containers they depend on are started. It doesn't have anything (yet) for app-specific logic which indicates whether the dependency is actually ready.

Here is a simple Python script which can be run inside of a container to delay starting the app code until preconditions are met.

Script

The following is the script which will run and wait until the preconditions defined in the yaml definition below are met

ready_wait.py

Configuration

The script above expects a configuration file at /etc/ready_wait.yaml like the following

hostname1:
  http:
    port: 80
    uri: /status
    status: 200
    contains: OK

hostname2:
  tcp:
    port: 80

Docker Usage

Modify the Docker container CMD to wait for ready_wait to complete before running the normal app entrypoint for your container. For example:

FROM ubuntu
ADD ready_wait.py /usr/bin/ready_wait
ADD ready_wait.yaml /etc/ready_wait.yaml
...
CMD ready_wait && /entrypoint.sh

About

No description, website, or topics provided.

Resources

Releases

No releases published

Packages

No packages published

Languages