Skip to content
Latchkey

dockerize: Usage, Options & Common CI Errors

dockerize waits for services (tcp/http) and renders config templates at startup.

dockerize is a small Go utility that makes a container wait for its dependencies before the main process starts - and can template config from env vars. The waits are protocol-prefixed, which is the most common thing people get wrong.

What it does

dockerize delays a command until specified dependencies are reachable (-wait), with an overall -timeout, and can render configuration files from Go templates populated by environment variables (-template). It is an entrypoint helper for service ordering and config injection in containers.

Common usage

Terminal
dockerize -wait tcp://db:5432 -timeout 60s ./start.sh
dockerize -wait http://api:8080/health -timeout 30s npm test
dockerize -wait tcp://db:5432 -wait tcp://redis:6379 -timeout 1m app
dockerize -template nginx.tmpl:/etc/nginx/nginx.conf nginx -g 'daemon off;'
dockerize -wait file:///data/ready -timeout 20s ./run.sh

Options

FlagWhat it does
-wait <url>Wait for a dependency (repeatable)
-timeout <dur>Give up after this duration (e.g. 30s, 1m)
-wait-retry-interval <dur>Time between dependency checks
-template <src>:<dst>Render a config template to a path
tcp:// http:// file://Supported wait protocols

Common errors in CI

The #1 mistake is the wait URL scheme: it must be tcp://host:port or http://host:port/path - a bare host:port is rejected, and using http:// against a non-HTTP port hangs until -timeout. "Timeout after 10s waiting on dependencies to become available" (default 10s) means the service was slow - raise -timeout. http:// waits expect a 200; a health endpoint returning 503 during warmup keeps it waiting. "dockerize: command not found" - it must be added to the image (it is not a Docker subcommand, despite the name).

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →