nginx-proxy/docker-gen

$CurrentContainer cannot be initialized when `-only-exposed` is used

bap2pecs opened this issue · 0 comments

If using docker-gen and nginx separately instead of nginx-proxy, the official template does not work when -only-exposed (or -only-published) is used.

After debugging, I found out that the root cause is $CurrentContainer is not initialized properly. This is expected because the docker-gen container does not expose any ports. So

{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}

cannot find the docker-gen container inside $ (the list of all containers)

A possible solution is to explicitly expose .CurrentContainer as a top-level argument to the template.