{"id":13394002,"url":"https://github.com/nginx-proxy/docker-gen","last_synced_at":"2025-12-16T23:30:46.185Z","repository":{"id":15036658,"uuid":"17762549","full_name":"nginx-proxy/docker-gen","owner":"nginx-proxy","description":"Generate files from docker container meta-data","archived":false,"fork":false,"pushed_at":"2025-09-05T22:02:00.000Z","size":5412,"stargazers_count":4575,"open_issues_count":52,"forks_count":614,"subscribers_count":84,"default_branch":"main","last_synced_at":"2025-09-06T19:06:58.216Z","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/nginx-proxy.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-03-14T22:34:35.000Z","updated_at":"2025-09-04T14:34:18.000Z","dependencies_parsed_at":"2023-07-17T18:15:03.067Z","dependency_job_id":"ea9f1b59-6084-4e78-9a79-f603614a7d57","html_url":"https://github.com/nginx-proxy/docker-gen","commit_stats":{"total_commits":400,"total_committers":64,"mean_commits":6.25,"dds":0.77,"last_synced_commit":"62cd9899a1089db8ba15875d63e471f8d76e99ef"},"previous_names":["jwilder/docker-gen"],"tags_count":64,"template":false,"template_full_name":null,"purl":"pkg:github/nginx-proxy/docker-gen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginx-proxy%2Fdocker-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginx-proxy%2Fdocker-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginx-proxy%2Fdocker-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginx-proxy%2Fdocker-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nginx-proxy","download_url":"https://codeload.github.com/nginx-proxy/docker-gen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginx-proxy%2Fdocker-gen/sbom","scorecard":{"id":545282,"data":{"date":"2025-08-11","repo":{"name":"github.com/nginx-proxy/docker-gen","commit":"5839d6d551f80243e2709188bf540adbc01a0bde"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.3,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/6 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: topLevel 'contents' permission set to 'write': .github/workflows/assets.yml:4","Info: topLevel 'contents' permission set to 'read': .github/workflows/build-publish-dispatch.yml:4","Warn: topLevel 'packages' permission set to 'write': .github/workflows/build-publish-dispatch.yml:5","Info: topLevel 'contents' permission set to 'read': .github/workflows/build-publish.yml:4","Warn: topLevel 'packages' permission set to 'write': .github/workflows/build-publish.yml:5","Info: topLevel 'contents' permission set to 'read': .github/workflows/dockerhub-description.yml:4","Info: topLevel 'contents' permission set to 'read': .github/workflows/tests.yml:4","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/build-publish-dispatch.yml:16"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/assets.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/assets.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/assets.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/assets.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/assets.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/assets.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-publish-dispatch.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish-dispatch.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish-dispatch.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish-dispatch.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish-dispatch.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish-dispatch.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish-dispatch.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish-dispatch.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish-dispatch.yml:54: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish-dispatch.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish-dispatch.yml:60: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish-dispatch.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish-dispatch.yml:68: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish-dispatch.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-publish.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish.yml:65: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish.yml:68: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish.yml:77: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-publish.yml:85: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/build-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/dockerhub-description.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/dockerhub-description.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/dockerhub-description.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/dockerhub-description.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/tests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/nginx-proxy/docker-gen/tests.yml/main?enable=pin","Warn: containerImage not pinned by hash: Dockerfile.alpine:4","Warn: containerImage not pinned by hash: Dockerfile.alpine:27: pin your Docker image by updating alpine:3.22.1 to alpine:3.22.1@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1","Warn: containerImage not pinned by hash: Dockerfile.debian:4","Warn: containerImage not pinned by hash: Dockerfile.debian:27: pin your Docker image by updating debian:13.0-slim to debian:13.0-slim@sha256:c85a2732e97694ea77237c61304b3bb410e0e961dd6ee945997a06c788c545bb","Info:   0 out of   7 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of  14 third-party GitHubAction dependencies pinned","Info:   0 out of   4 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Branch-Protection","score":6,"reason":"branch protection is not maximal on development and all release branches","details":["Info: 'allow deletion' disabled on branch 'main'","Info: 'force pushes' disabled on branch 'main'","Warn: required approving review count is 1 on branch 'main'","Warn: codeowners review is not required on branch 'main'","Warn: no status checks found to merge onto branch 'main'","Info: PRs are required in order to make changes on branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 0.15.0 not signed: https://api.github.com/repos/nginx-proxy/docker-gen/releases/234376113","Warn: release artifact 0.14.7 not signed: https://api.github.com/repos/nginx-proxy/docker-gen/releases/217304912","Warn: release artifact 0.14.6 not signed: https://api.github.com/repos/nginx-proxy/docker-gen/releases/207701481","Warn: release artifact 0.14.5 not signed: https://api.github.com/repos/nginx-proxy/docker-gen/releases/195506385","Warn: release artifact 0.14.4 not signed: https://api.github.com/repos/nginx-proxy/docker-gen/releases/187179120","Warn: release artifact 0.15.0 does not have provenance: https://api.github.com/repos/nginx-proxy/docker-gen/releases/234376113","Warn: release artifact 0.14.7 does not have provenance: https://api.github.com/repos/nginx-proxy/docker-gen/releases/217304912","Warn: release artifact 0.14.6 does not have provenance: https://api.github.com/repos/nginx-proxy/docker-gen/releases/207701481","Warn: release artifact 0.14.5 does not have provenance: https://api.github.com/repos/nginx-proxy/docker-gen/releases/195506385","Warn: release artifact 0.14.4 does not have provenance: https://api.github.com/repos/nginx-proxy/docker-gen/releases/187179120"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":10,"reason":"SAST tool is run on all commits","details":["Info: all commits (29) are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2025-3829 / GHSA-4vq8-7jfc-9cvp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T09:20:40.737Z","repository_id":15036658,"created_at":"2025-08-20T09:20:40.737Z","updated_at":"2025-08-20T09:20:40.737Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273983110,"owners_count":25202095,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-30T17:01:05.221Z","updated_at":"2025-12-16T23:30:41.128Z","avatar_url":"https://github.com/nginx-proxy.png","language":"Go","readme":"# docker-gen\n\n[![Tests](https://github.com/nginx-proxy/docker-gen/actions/workflows/tests.yml/badge.svg)](https://github.com/nginx-proxy/docker-gen/actions/workflows/tests.yml)\n[![GitHub release](https://img.shields.io/github/v/release/nginx-proxy/docker-gen)](https://github.com/nginx-proxy/docker-gen/releases)\n[![Docker Image Size](https://img.shields.io/docker/image-size/nginxproxy/docker-gen?sort=semver)](https://hub.docker.com/r/nginxproxy/docker-gen \"Click to view the image on Docker Hub\")\n[![Docker stars](https://img.shields.io/docker/stars/nginxproxy/docker-gen.svg)](https://hub.docker.com/r/nginxproxy/docker-gen \"DockerHub\")\n[![Docker pulls](https://img.shields.io/docker/pulls/nginxproxy/docker-gen.svg)](https://hub.docker.com/r/nginxproxy/docker-gen \"DockerHub\")\n\n`docker-gen` is a file generator that renders templates using docker container meta-data.\n\nIt can be used to generate various kinds of files for:\n\n- **Centralized logging** - [fluentd](https://github.com/nginx-proxy/docker-gen/blob/main/templates/fluentd.conf.tmpl), logstash or other centralized logging tools that tail the containers JSON log file or files within the container.\n- **Log Rotation** - [logrotate](https://github.com/nginx-proxy/docker-gen/blob/main/templates/logrotate.tmpl) files to rotate container JSON log files\n- **Reverse Proxy Configs** - [nginx](https://github.com/nginx-proxy/docker-gen/blob/main/templates/nginx.tmpl), [haproxy](https://github.com/jwilder/docker-discover), etc. reverse proxy configs to route requests from the host to containers\n- **Service Discovery** - Scripts (python, bash, etc..) to register containers within [etcd](https://github.com/jwilder/docker-register), hipache, etc..\n\n---\n\n### Installation\n\nThere are three common ways to run docker-gen:\n\n- on the host\n- bundled in a container with another application\n- separate standalone containers\n\n#### Host Install\n\nDownload the version you need, untar, and install to your PATH.\n\n```console\nwget https://github.com/nginx-proxy/docker-gen/releases/download/0.12.0/docker-gen-linux-amd64-0.12.0.tar.gz\ntar xvzf docker-gen-linux-amd64-0.12.0.tar.gz\n./docker-gen\n```\n\n#### Bundled Container Install\n\nDocker-gen can be bundled inside of a container along-side applications.\n\n[nginx-proxy/nginx-proxy](https://hub.docker.com/r/nginxproxy/nginx-proxy) trusted build is an example of\nrunning docker-gen within a container along-side nginx.\n[jwilder/docker-register](https://github.com/jwilder/docker-register) is an example of running\ndocker-gen within a container to do service registration with etcd.\n\n#### Separate Container Install\n\nIt can also be run as two separate containers using the [nginx-proxy/docker-gen](https://hub.docker.com/r/nginxproxy/docker-gen)\nimage, together with virtually any other image.\n\nThis is how you could run the official [nginx](https://registry.hub.docker.com/_/nginx/) image and\nhave docker-gen generate a reverse proxy config in the same way that `nginx-proxy` works. You may want to do\nthis to prevent having the docker socket bound to a publicly exposed container service.\n\nStart nginx with a shared volume:\n\n```console\ndocker run -d -p 80:80 --name nginx -v /tmp/nginx:/etc/nginx/conf.d -t nginx\n```\n\nFetch the template and start the docker-gen container with the shared volume:\n\n```console\nmkdir -p /tmp/templates \u0026\u0026 cd /tmp/templates\ncurl -o nginx.tmpl https://raw.githubusercontent.com/nginx-proxy/docker-gen/main/templates/nginx.tmpl\ndocker run -d --name nginx-gen --volumes-from nginx \\\n   -v /var/run/docker.sock:/tmp/docker.sock:rw \\\n   -v /tmp/templates:/etc/docker-gen/templates \\\n   -t nginxproxy/docker-gen -notify-sighup nginx -watch -only-exposed /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf\n```\n\nStart a container, taking note of any Environment variables a container expects. See the top of a template for details.\n\n```console\ndocker run --env VIRTUAL_HOST='example.com' --env VIRTUAL_PORT=80 ...\n```\n\n---\n\n### Usage\n\n```\n$ docker-gen\nUsage: docker-gen [options] template [dest]\n\nGenerate files from docker container meta-data\n\nOptions:\n  -config value\n      config files with template directives. Config files will be merged if this option is specified multiple times. (default [])\n  -endpoint string\n      docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock\n  -event-filter value\n      additional filter for event watched by docker-gen (e.g -event-filter event=connect -event-filter event=disconnect).\n      You can pass this option multiple times to combine filters.\n      By default docker-gen listen for container events start, stop, die and health_status.\n      https://docs.docker.com/engine/reference/commandline/events/#filtering-events\n  -interval int\n      notify command interval (secs)\n  -keep-blank-lines\n      keep blank lines in the output file\n  -notify restart xyz\n      run command after template is regenerated (e.g restart xyz)\n  -notify-output\n      log the output(stdout/stderr) of notify command\n  -notify-sighup container-ID\n      send HUP signal to container.\n      Equivalent to 'docker kill -s HUP container-ID', or `-notify-container container-ID -notify-signal 1`.\n      You can pass this option multiple times to send HUP to multiple containers.\n  -notify-container container-ID\n      send -notify-signal signal (defaults to 1 / HUP) to container.\n      You can pass this option multiple times to notify multiple containers.\n  -notify-filter key=value\n      container filter for notification (e.g -notify-filter name=foo).\n      You can pass this option multiple times to combine filters with AND.\n      https://docs.docker.com/engine/reference/commandline/ps/#filter\n  -notify-signal signal\n      signal to send to the -notify-container and -notify-filter. -1 to call docker restart. Defaults to 1 aka. HUP.\n      All available signals available on the dockerclient\n      https://github.com/fsouza/go-dockerclient/blob/main/signal.go\n  -only-exposed\n      only include containers with exposed ports\n  -only-published\n      only include containers with published ports (implies -only-exposed)\n  -include-stopped\n      include stopped containers\n  -tlscacert string\n      path to TLS CA certificate file (default \"~/.docker/machine/machines/default/ca.pem\")\n  -tlscert string\n      path to TLS client certificate file (default \"~/.docker/machine/machines/default/cert.pem\")\n  -tlskey string\n      path to TLS client key file (default \"~/.docker/machine/machines/default/key.pem\")\n  -tlsverify\n      verify docker daemon's TLS certicate (default true)\n  -version\n      show version\n  -watch\n      watch for container changes\n  -wait\n      minimum (and/or maximum) duration to wait after each container change before triggering\n\nArguments:\n  template - path to a template to generate\n  dest - path to write the template. If not specfied, STDOUT is used\n\nEnvironment Variables:\n  DOCKER_HOST - default value for -endpoint\n  DOCKER_CERT_PATH - directory path containing key.pem, cert.pm and ca.pem\n  DOCKER_TLS_VERIFY - enable client TLS verification]\n```\n\nIf no `\u003cdest\u003e` file is specified, the output is sent to stdout. Mainly useful for debugging.\n\n### Configuration file\n\nUsing the -config flag from above you can tell docker-gen to use the specified config file instead of command-line options. Multiple templates can be defined and they will be executed in the order that they appear in the config file.\n\nAn example configuration file, **docker-gen.cfg** can be found in the examples folder.\n\n#### Configuration File Syntax\n\n```ini\n[[config]]\n# Starts a configuration section\n\ndest = \"path/to/a/file\"\n# path to write the template. If not specfied, STDOUT is used\n\nnotifycmd = \"/etc/init.d/foo reload\"\n# run command after template is regenerated (e.g restart xyz)\n\nonlyexposed = true\n# only include containers with exposed ports\n\ntemplate = \"/path/to/a/template/file.tmpl\"\n# path to a template to generate\n\nwatch = true\n# watch for container changes\n\nwait = \"500ms:2s\"\n# debounce changes with a min:max duration. Only applicable if watch = true\n\n\n[config.NotifyContainers]\n# Starts a notify container section\n\ncontainername = 1\n# container name followed by the signal to send\n\ncontainer_id = 1\n# or the container id can be used followed by the signal to send\n```\n\nPutting it all together here is an example configuration file.\n\n```ini\n[[config]]\ntemplate = \"/etc/nginx/nginx.conf.tmpl\"\ndest = \"/etc/nginx/sites-available/default\"\nonlyexposed = true\nnotifycmd = \"/etc/init.d/nginx reload\"\n\n[[config]]\ntemplate = \"/etc/logrotate.conf.tmpl\"\ndest = \"/etc/logrotate.d/docker\"\nwatch = true\n\n[[config]]\ntemplate = \"/etc/docker-gen/templates/nginx.tmpl\"\ndest = \"/etc/nginx/conf.d/default.conf\"\nwatch = true\nwait = \"500ms:2s\"\n\n[config.NotifyContainers]\nnginx = 1  # 1 is a signal number to be sent; here SIGHUP\ne75a60548dc9 = 1  # a key can be either container name (nginx) or ID\n```\n\n---\n\n### Templating\n\nThe templates used by docker-gen are written using the Go [text/template](http://golang.org/pkg/text/template/) language. In addition to the [built-in functions](http://golang.org/pkg/text/template/#hdr-Functions) supplied by Go, docker-gen uses [sprig](https://masterminds.github.io/sprig/) and some additional functions to make it simpler (or possible) to generate your desired output. Some templates rely on environment variables within the container to make decisions on what to generate from the template.\n\nSeveral templates may be parsed at once by using a semicolon (`;`) to delimit the `template` value. This can be used as a proxy for Golang's nested template functionality. In all cases, the main rendered template should go first.\n\n```\n[[config]]\ntemplate = \"/etc/docker-gen/templates/nginx.tmpl;/etc/docker-gen/templates/header.tmpl\"\ndest = \"/etc/nginx/conf.d/default.conf\"\nwatch = true\nwait = \"500ms:2s\"\n```\n\n#### Emit Structure\n\nWithin the templates, the object emitted by docker-gen will be a structure consisting of following Go structs:\n\n```go\ntype RuntimeContainer struct {\n    ID           string\n    Created      time.Time\n    Addresses    []Address\n    Networks     []Network\n    Gateway      string\n    Name         string\n    Hostname     string\n    Image        DockerImage\n    Env          map[string]string\n    Volumes      map[string]Volume\n    Node         SwarmNode\n    Labels       map[string]string\n    IP           string\n    IP6LinkLocal string\n    IP6Global    string\n    Mounts       []Mount\n    State        State\n}\n\ntype Address struct {\n    IP           string\n    IP6LinkLocal string\n    IP6Global    string\n    Port         string\n    HostPort     string\n    Proto        string\n    HostIP       string\n}\n\ntype Network struct {\n    IP                  string\n    Name                string\n    Gateway             string\n    EndpointID          string\n    IPv6Gateway         string\n    GlobalIPv6Address   string\n    MacAddress          string\n    GlobalIPv6PrefixLen int\n    IPPrefixLen         int\n    Internal            bool\n}\n\ntype DockerImage struct {\n    Registry   string\n    Repository string\n    Tag        string\n}\n\ntype Mount struct {\n  Name        string\n  Source      string\n  Destination string\n  Driver      string\n  Mode        string\n  RW          bool\n}\n\ntype Volume struct {\n    Path      string\n    HostPath  string\n    ReadWrite bool\n}\n\ntype SwarmNode struct {\n    ID      string\n    Name    string\n    Address Address\n}\n\ntype State struct {\n\tRunning bool\n\tHealth  Health\n}\n\ntype Health struct {\n\tStatus string\n}\n\n// Accessible from the root in templates as .Docker\ntype Docker struct {\n    Name                 string\n    NumContainers        int\n    NumImages            int\n    Version              string\n    ApiVersion           string\n    GoVersion            string\n    OperatingSystem      string\n    Architecture         string\n    CurrentContainerID   string\n}\n\n// Host environment variables accessible from root in templates as .Env\n```\n\nFor example, this is a JSON version of an emitted RuntimeContainer struct:\n\n```json\n{\n  \"ID\": \"71e9768075836eb38557adcfc71a207386a0c597dbeda240cf905df79b18cebf\",\n  \"Addresses\": [\n    {\n      \"IP\": \"172.17.0.4\",\n      \"Port\": \"22\",\n      \"Proto\": \"tcp\",\n      \"HostIP\": \"192.168.10.24\",\n      \"HostPort\": \"2222\"\n    }\n  ],\n  \"Gateway\": \"172.17.42.1\",\n  \"Node\": {\n    \"ID\": \"I2VY:P7PF:TZD5:PGWB:QTI7:QDSP:C5UD:DYKR:XKKK:TRG2:M2BL:DFUN\",\n    \"Name\": \"docker-test\",\n    \"Address\": {\n      \"IP\": \"192.168.10.24\"\n    }\n  },\n  \"Labels\": {\n    \"operatingsystem\": \"Ubuntu 14.04.2 LTS\",\n    \"storagedriver\": \"devicemapper\",\n    \"anything_foo\": \"something_bar\"\n  },\n  \"IP\": \"172.17.0.4\",\n  \"Name\": \"docker_register\",\n  \"Hostname\": \"71e976807583\",\n  \"Image\": {\n    \"Registry\": \"jwilder\",\n    \"Repository\": \"docker-register\"\n  },\n  \"Env\": {\n    \"ETCD_HOST\": \"172.17.42.1:4001\",\n    \"PATH\": \"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\",\n    \"DOCKER_HOST\": \"unix:///var/run/docker.sock\",\n    \"HOST_IP\": \"172.17.42.1\"\n  },\n  \"Volumes\": {\n    \"/mnt\": {\n      \"Path\": \"/mnt\",\n      \"HostPath\": \"/Users/joebob/tmp\",\n      \"ReadWrite\": true\n    }\n  }\n}\n```\n\n#### Functions\n\n- [Functions from Go](https://pkg.go.dev/text/template#hdr-Functions)\n- [Functions from Sprig v3](https://masterminds.github.io/sprig/), except for those that have the same name as one of the following functions.\n- _`closest $array $value`_: Returns the longest matching substring in `$array` that matches `$value`\n- _`coalesce ...`_: Returns the first non-nil argument.\n- _`comment $delimiter $string`_: Returns `$string` with each line prefixed by `$delimiter` (helpful for debugging combined with Sprig `toPrettyJson`: `{{ toPrettyJson $ | comment \"#\" }}`).\n- _`contains $map $key`_: Returns `true` if `$map` contains `$key`. Takes maps from `string` to any type.\n- _`dir $path`_: Returns an array of filenames in the specified `$path`.\n- _`exists $path`_: Returns `true` if `$path` refers to an existing file or directory. Takes a string.\n- _`eval $templateName [$data]`_: Evaluates the named template like Go's built-in `template` action, but instead of writing out the result it returns the result as a string so that it can be post-processed. The `$data` argument may be omitted, which is equivalent to passing `nil`.\n- _`groupBy $containers $fieldPath`_: Groups an array of `RuntimeContainer` instances based on the values of a field path expression `$fieldPath`. A field path expression is a dot-delimited list of map keys or struct member names specifying the path from container to a nested value, which must be a string. Returns a map from the value of the field path expression to an array of containers having that value. Containers that do not have a value for the field path in question are omitted.\n- _`groupByWithDefault $containers $fieldPath $defaultValue`_: Returns the same as `groupBy`, but containers that do not have a value for the field path are instead included in the map under the `$defaultValue` key.\n- _`groupByKeys $containers $fieldPath`_: Returns the same as `groupBy` but only returns the keys of the map.\n- _`groupByMulti $containers $fieldPath $sep`_: Like `groupBy`, but the string value specified by `$fieldPath` is first split by `$sep` into a list of strings. A container whose `$fieldPath` value contains a list of strings will show up in the map output under each of those strings.\n- _`groupByLabel $containers $label`_: Returns the same as `groupBy` but grouping by the given label's value. Containers that do not have the `$label` set are omitted.\n- _`groupByLabelWithDefault $containers $label $defaultValue`_: Returns the same as `groupBy` but grouping by the given label's value. Containers that do not have the `$label` set are included in the map under the `$defaultValue` key.\n- _`include $file`_: Returns content of `$file`, and empty string if file reading error.\n- _`intersect $slice1 $slice2`_: Returns the strings that exist in both string slices.\n- _`fromYaml $string` / `mustFromYaml $string`_: Similar to [Sprig's `fromJson` / `mustFromJson`](https://github.com/Masterminds/sprig/blob/master/docs/defaults.md#fromjson-mustfromjson), but for YAML.\n- _`toYaml $dict` / `mustToYaml $dict`_: Similar to [Sprig's `toJson` / `mustToJson`](https://github.com/Masterminds/sprig/blob/master/docs/defaults.md#tojson-musttojson), but for YAML.\n- _`keys $map`_: Returns the keys from `$map`. If `$map` is `nil`, a `nil` is returned. If `$map` is not a `map`, an error will be thrown.\n- _`sortStringsAsc $strings`_: Returns a slice of strings `$strings` sorted in ascending order.\n- _`sortStringsDesc $strings`_: Returns a slice of strings `$strings` sorted in descending (reverse) order.\n- _`sortObjectsByKeysAsc $objects $fieldPath`_: Returns the array `$objects`, sorted in ascending order based on the values of a field path expression `$fieldPath`.\n- _`sortObjectsByKeysDesc $objects $fieldPath`_: Returns the array `$objects`, sorted in descending (reverse) order based on the values of a field path expression `$fieldPath`.\n- _`when $condition $trueValue $falseValue`_: Returns the `$trueValue` when the `$condition` is `true` and the `$falseValue` otherwise\n- _`where $items $fieldPath $value`_: Filters an array or slice based on the values of a field path expression `$fieldPath`. A field path expression is a dot-delimited list of map keys or struct member names specifying the path from container to a nested value. Returns an array of items having that value.\n- _`whereNot $items $fieldPath $value`_: Filters an array or slice based on the values of a field path expression `$fieldPath`. A field path expression is a dot-delimited list of map keys or struct member names specifying the path from container to a nested value. Returns an array of items **not** having that value.\n- _`whereExist $items $fieldPath`_: Like `where`, but returns only items where `$fieldPath` exists (is not nil).\n- _`whereNotExist $items $fieldPath`_: Like `where`, but returns only items where `$fieldPath` does not exist (is nil).\n- _`whereAny $items $fieldPath $sep $values`_: Like `where`, but the string value specified by `$fieldPath` is first split by `$sep` into a list of strings. The comparison value is a string slice with possible matches. Returns items which OR intersect these values.\n- _`whereAll $items $fieldPath $sep $values`_: Like `whereAny`, except all `$values` must exist in the `$fieldPath`.\n- _`whereLabelExists $containers $label`_: Filters a slice of containers based on the existence of the label `$label`.\n- _`whereLabelDoesNotExist $containers $label`_: Filters a slice of containers based on the non-existence of the label `$label`.\n- _`whereLabelValueMatches $containers $label $pattern`_: Filters a slice of containers based on the existence of the label `$label` with values matching the regular expression `$pattern`.\n\nSprig functions that have the same name as docker-gen function (but different behaviour) are made available with the `sprig` prefix:\n\n- _`sprigCoalesce ...`_: Alias for Sprig's [`coalesce`](https://masterminds.github.io/sprig/defaults.html).\n- _`sprigContains $string $string`_: Alias for Sprig's [`contains`](https://masterminds.github.io/sprig/strings.html).\n- _`sprigDir $path`_: Alias for Sprig's [`dir`](https://masterminds.github.io/sprig/paths.html).\n- _`sprigReplace $old $new $string`_: Alias for Sprig's [`replace`](https://masterminds.github.io/sprig/strings.html).\n- _`sprigSplit $sep $string`_: Alias for Sprig's [`split`](https://masterminds.github.io/sprig/string_slice.html).\n- _`sprigSplitn $sep $count $string\"`_: Alias for Sprig's [`splitn`](https://masterminds.github.io/sprig/string_slice.html).\n\nSome functions are aliases for Go's [`strings`](https://pkg.go.dev/strings) package functions:\n\n- _`parseBool $string`_: Alias for [`strconv.ParseBool`](http://golang.org/pkg/strconv/#ParseBool). Returns the boolean value represented by `$string`. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.\n- _`replace $string $old $new $count`_: Alias for [`strings.Replace`](http://golang.org/pkg/strings/#Replace). Replaces up to `$count` occurences of `$old` with `$new` in `$string`.\n- _`split $string $sep`_: Alias for [`strings.Split`](http://golang.org/pkg/strings/#Split). Splits `$string` into a slice of substrings delimited by `$sep`.\n- _`splitN $string $sep $count`_: Alias for [`strings.SplitN`](https://golang.org/pkg/strings/#SplitN). Splits `$string` into a slice of substrings delimited by `$sep`, with number of substrings returned determined by `$count`.\n- _`toLower $string`_: Alias for [`strings.ToLower`](https://pkg.go.dev/strings#ToLower). Replace capital letters in `$string` to lowercase.\n- _`toUpper $string`_: Alias for [`strings.ToUpper`](https://pkg.go.dev/strings#ToUpper). Replace lowercase letters in `$string` to uppercase.\n\nThose have been aliased to Sprig functions with the same behaviour as the original docker-gen function:\n\n- _`json $value`_: Alias for Sprig's [`mustToJson`](https://masterminds.github.io/sprig/defaults.html)\n- _`parseJson $string`_: Alias for Sprig's [`mustFromJson`](https://masterminds.github.io/sprig/defaults.html).\n- _`sha1 $string`_: Alias for Sprig's [`sha1sum`](https://masterminds.github.io/sprig/crypto.html).\n\n---\n\n### Examples\n\n- [Automated Nginx Reverse Proxy for Docker](http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/)\n- [Docker Log Management With Fluentd](http://jasonwilder.com/blog/2014/03/17/docker-log-management-using-fluentd/)\n- [Docker Service Discovery Using Etcd and Haproxy](http://jasonwilder.com/blog/2014/07/15/docker-service-discovery/)\n\n#### NGINX Reverse Proxy Config\n\n[nginxproxy/nginx-proxy](https://hub.docker.com/r/nginxproxy/nginx-proxy) trusted build.\n\nStart nginx-proxy:\n\n```console\ndocker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock -t nginxproxy/nginx-proxy\n```\n\nThen start containers with a VIRTUAL_HOST (and the VIRTUAL_PORT if more than one port is exposed) env variable:\n\n```console\ndocker run -e VIRTUAL_HOST=foo.bar.com -e VIRTUAL_PORT=80 -t ...\n```\n\nIf you wanted to run docker-gen directly on the host, you could do it with:\n\n```console\ndocker-gen -only-published -watch -notify \"/etc/init.d/nginx reload\" templates/nginx.tmpl /etc/nginx/sites-enabled/default\n```\n\n#### Fluentd Log Management\n\nThis template generate a fluentd.conf file used by fluentd. It would then ship log files off\nthe host.\n\n```console\ndocker-gen -watch -notify \"restart fluentd\" templates/fluentd.tmpl /etc/fluent/fluent.conf\n```\n\n#### Service Discovery in Etcd\n\nThis template is an example of generating a script that is then executed. This template generates\na python script that is then executed which register containers in Etcd using its HTTP API.\n\n```console\ndocker-gen -notify \"/bin/bash /tmp/etcd.sh\" -interval 10 templates/etcd.tmpl /tmp/etcd.sh\n```\n\n### Development\n\nThis project uses [Go Modules](https://golang.org/ref/mod) for managing 3rd party dependencies.\nThis means that at least `go 1.11` is required.\n\nFor `go 1.11` and `go 1.12` it is additionally required to manually enable support by setting `GO111MODULE=on`.\nFor later versions, this is not required.\n\n```console\ngit clone \u003cyour fork\u003e\ncd \u003cyour fork\u003e\nmake get-deps\nmake\n```\n\n### Powered by \n\n[![GoLand logo](https://resources.jetbrains.com/storage/products/company/brand/logos/GoLand_icon.svg)](https://www.jetbrains.com/go/)\n","funding_links":[],"categories":["Go","Repositories","go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnginx-proxy%2Fdocker-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnginx-proxy%2Fdocker-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnginx-proxy%2Fdocker-gen/lists"}