{"id":13416413,"url":"https://github.com/jwilder/dockerize","last_synced_at":"2025-05-12T05:25:23.598Z","repository":{"id":21855597,"uuid":"25178920","full_name":"jwilder/dockerize","owner":"jwilder","description":"Utility to simplify running applications in docker containers","archived":false,"fork":false,"pushed_at":"2025-04-25T17:44:42.000Z","size":156,"stargazers_count":5059,"open_issues_count":54,"forks_count":417,"subscribers_count":87,"default_branch":"master","last_synced_at":"2025-05-08T22:00:04.984Z","etag":null,"topics":["docker","go"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwilder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-10-13T21:36:02.000Z","updated_at":"2025-05-07T22:20:59.000Z","dependencies_parsed_at":"2023-01-14T13:12:58.796Z","dependency_job_id":"49546408-da9e-407c-b881-f135530d3e49","html_url":"https://github.com/jwilder/dockerize","commit_stats":{"total_commits":136,"total_committers":48,"mean_commits":"2.8333333333333335","dds":0.5955882352941176,"last_synced_commit":"c16c362dcc2c02b1c57f7e34f26961937fee80d1"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilder%2Fdockerize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilder%2Fdockerize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilder%2Fdockerize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilder%2Fdockerize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwilder","download_url":"https://codeload.github.com/jwilder/dockerize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253154969,"owners_count":21862621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","go"],"created_at":"2024-07-30T21:00:58.477Z","updated_at":"2025-05-08T22:02:04.863Z","avatar_url":"https://github.com/jwilder.png","language":"Go","readme":"dockerize ![version v0.9.3](https://img.shields.io/badge/version-v0.9.3-brightgreen.svg) ![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)\n=============\n\nUtility to simplify running applications in docker containers.\n\ndockerize is a utility to simplify running applications in docker containers.  It allows you to:\n* generate application configuration files at container startup time from templates and container environment variables\n* Tail multiple log files to stdout and/or stderr\n* Wait for other services to be available using TCP, HTTP(S), unix before starting the main process.\n\nThe typical use case for dockerize is when you have an application that has one or more configuration files and you would like to control some of the values using environment variables.\n\nFor example, a Python application using Sqlalchemy might not be able to use environment variables directly.\nIt may require that the database URL be read from a python settings file with a variable named\n`SQLALCHEMY_DATABASE_URI`.  dockerize allows you to set an environment variable such as\n`DATABASE_URL` and update the python file when the container starts.\nIn addition, it can also delay the starting of the python application until the database container is running and listening on the TCP port.\n\nAnother use case is when the application logs to specific files on the filesystem and not stdout\nor stderr. This makes it difficult to troubleshoot the container using the `docker logs` command.\nFor example, nginx will log to `/var/log/nginx/access.log` and\n`/var/log/nginx/error.log` by default. While you can sometimes work around this, it's tedious to find a solution for every application. dockerize allows you to specify which logs files should be tailed and where they should be sent.\n\nSee [A Simple Way To Dockerize Applications](http://jasonwilder.com/blog/2014/10/13/a-simple-way-to-dockerize-applications/)\n\n\n## Installation\n\nDownload the latest version in your container:\n\n* [linux/amd64](https://github.com/jwilder/dockerize/releases/download/v0.9.3/dockerize-linux-amd64-v0.9.3.tar.gz)\n* [alpine/amd64](https://github.com/jwilder/dockerize/releases/download/v0.9.3/dockerize-alpine-linux-amd64-v0.9.3.tar.gz)\n* [darwin/amd64](https://github.com/jwilder/dockerize/releases/download/v0.9.3/dockerize-darwin-amd64-v0.9.3.tar.gz)\n\n\n### Docker Base Image\n\nThe `jwilder/dockerize` image is a base image based on `gcr.io/distroless/static`.  `dockerize` is installed in the `$PATH` and can be used directly.\n\n```\nFROM jwilder/dockerize\n...\nENTRYPOINT dockerize ...\n```\n\n### Ubuntu Images\n\n``` Dockerfile\nENV DOCKERIZE_VERSION v0.9.3\n\nRUN apt-get update \\\n    \u0026\u0026 apt-get install -y wget \\\n    \u0026\u0026 wget -O - https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | tar xzf - -C /usr/local/bin \\\n    \u0026\u0026 apt-get autoremove -yqq --purge wget \u0026\u0026 rm -rf /var/lib/apt/lists/*\n```\n\n\n### For Alpine Images:\n\n``` Dockerfile\nENV DOCKERIZE_VERSION v0.9.3\n\nRUN apk update --no-cache \\\n    \u0026\u0026 apk add --no-cache wget openssl \\\n    \u0026\u0026 wget -O - https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz | tar xzf - -C /usr/local/bin \\\n    \u0026\u0026 apk del wget\n```\n\n## Usage\n\ndockerize works by wrapping the call to your application using the `ENTRYPOINT` or `CMD` directives.\n\nThis would generate `/etc/nginx/nginx.conf` from the template located at `/etc/nginx/nginx.tmpl` and\nsend `/var/log/nginx/access.log` to `STDOUT` and `/var/log/nginx/error.log` to `STDERR` after running\n`nginx`, only after waiting for the `web` host to respond on `tcp 8000`:\n\n``` Dockerfile\nCMD dockerize -template /etc/nginx/nginx.tmpl:/etc/nginx/nginx.conf -stdout /var/log/nginx/access.log -stderr /var/log/nginx/error.log -wait tcp://web:8000 nginx\n```\n\n### Command-line Options\n\nYou can specify multiple templates by passing using `-template` multiple times:\n\n```\n$ dockerize -template template1.tmpl:file1.cfg -template template2.tmpl:file3\n\n```\n\nTemplates can be generated to `STDOUT` by not specifying a dest:\n\n```\n$ dockerize -template template1.tmpl\n\n```\n\nTemplate may also be a directory. In this case all files within this directory are processed as template and stored with the same name in the destination directory.\nIf the destination directory is omitted, the output is sent to `STDOUT`. The files in the source directory are processed in sorted order (as returned by `ioutil.ReadDir`).\n\n```\n$ dockerize -template src_dir:dest_dir\n\n```\n\nIf the destination file already exists, dockerize will overwrite it. The -no-overwrite flag overrides this behaviour.\n\n```\n$ dockerize -no-overwrite -template template1.tmpl:file\n```\n\nYou can tail multiple files to `STDOUT` and `STDERR` by passing the options multiple times.\n\n```\n$ dockerize -stdout info.log -stdout perf.log\n\n```\n\nIf `inotify` does not work in your container, you can use `-poll` to poll for file changes instead.\n\n```\n$ dockerize -stdout info.log -stdout perf.log -poll\n\n```\n\nIf your file uses `{{` and `}}` as part of it's syntax, you can change the template escape characters using the `-delims`.\n\n```\n$ dockerize -delims \"\u003c%:%\u003e\"\n```\n\nHttp headers can be specified for http/https protocols.\n\n```\n$ dockerize -wait http://web:80 -wait-http-header \"Authorization:Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\"\n```\n\n## Waiting for other dependencies\n\nIt is common when using tools like [Docker Compose](https://docs.docker.com/compose/) to depend on services in other linked containers, however oftentimes relying on [links](https://docs.docker.com/compose/compose-file/#links) is not enough - whilst the container itself may have _started_, the _service(s)_ within it may not yet be ready - resulting in shell script hacks to work around race conditions.\n\nDockerize gives you the ability to wait for services on a specified protocol (`file`, `tcp`, `tcp4`, `tcp6`, `http`, `https` and `unix`) before starting your application:\n\n```\n$ dockerize -wait tcp://db:5432 -wait http://web:80 -wait file:///tmp/generated-file\n```\n\n### Timeout\n\nYou can optionally specify how long to wait for the services to become available by using the `-timeout #` argument (Default: 10 seconds).  If the timeout is reached and the service is still not available, the process exits with status code 1.\n\n```\n$ dockerize -wait tcp://db:5432 -wait http://web:80 -timeout 10s\n```\n\nSee [this issue](https://github.com/docker/compose/issues/374#issuecomment-126312313) for a deeper discussion, and why support isn't and won't be available in the Docker ecosystem itself.\n\n## Using Templates\n\nTemplates use Golang [text/template](http://golang.org/pkg/text/template/). You can access environment\nvariables within a template with `.Env`.\n\n```\n{{ .Env.PATH }} is my path\n```\n\nThere are a few built-in functions as well:\n\n  * `default $var $default` - Returns a default value for one that does not exist. `{{ default .Env.VERSION \"0.1.2\" }}`\n  * `contains $map $key` - Returns true if a string is within another string\n  * `exists $path` - Determines if a file path exists or not. `{{ exists \"/etc/default/myapp\" }}`\n  * `split $string $sep` - Splits a string into an array using a separator string. Alias for [`strings.Split`][go.string.Split]. `{{ split .Env.PATH \":\" }}`\n  * `replace $string $old $new $count` - Replaces all occurrences of a string within another string. Alias for [`strings.Replace`][go.string.Replace]. `{{ replace .Env.PATH \":\" }}`\n  * `parseUrl $url` - Parses a URL into it's [protocol, scheme, host, etc. parts][go.url.URL]. Alias for [`url.Parse`][go.url.Parse]\n  * `atoi $value` - Parses a string $value into an int. `{{ if (gt (atoi .Env.NUM_THREADS) 1) }}`\n  * `add $arg1 $arg` - Performs integer addition. `{{ add (atoi .Env.SHARD_NUM) -1 }}`\n  * `isTrue $value` - Parses a string $value to a boolean value. `{{ if isTrue .Env.ENABLED }}`\n  * `lower $value` - Lowercase a string.\n  * `upper $value` - Uppercase a string.\n  * `jsonQuery $json $query` - Returns the result of a selection query against a json document.\n  * `loop` - Create for loops.\n\n### jsonQuery\n\nObjects and fields are accessed by name. Array elements are accessed by index in square brackets (e.g. `[1]`). Nested elements are separated by dots (`.`).\n\n**Examples:**\n\nWith the following JSON in `.Env.SERVICES`\n\n```\n{\n  \"services\": [\n    {\n      \"name\": \"service1\",\n      \"port\": 8000,\n    },{\n      \"name\": \"service2\",\n      \"port\": 9000,\n    }\n  ]\n}\n```\n\nthe template expression `jsonQuery .Env.SERVICES \"services.[1].port\"` returns `9000`.\n\n### loop\n\n`loop` allows for creating for loop within a template.  It takes 1 to 3 arguments.\n\n```\n# Loop from 0...10\n{{ range loop 10 }}\ni = {{ . }}\n{{ end }}\n\n# Loop from 5...10\n{{ range $i := loop 5 10 }}\ni = {{ $i }}\n{{ end }}\n\n# Loop from 5...10 by 2\n{{ range $i := loop 5 10 2 }}\ni = {{ $i }}\n{{ end }}\n```\n\n## License\n\nMIT\n\n\n[go.string.Split]: https://golang.org/pkg/strings/#Split\n[go.string.Replace]: https://golang.org/pkg/strings/#Replace\n[go.url.Parse]: https://golang.org/pkg/net/url/#Parse\n[go.url.URL]: https://golang.org/pkg/net/url/#URL\n","funding_links":[],"categories":["Docker Images","Go","Misc","Systems/Software Development","Dev Tools","go","Uncategorized","Repositories"],"sub_categories":["Base Tools","Containers / Docker","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwilder%2Fdockerize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwilder%2Fdockerize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwilder%2Fdockerize/lists"}