docker-gen icon indicating copy to clipboard operation
docker-gen copied to clipboard

How to pass parameters into template!?

Open FractalMind opened this issue 7 years ago • 1 comments

I'm running in circles here...

I want to pass parameters DURING CONTAINER RUNTIME from a hostsList.csv to a nginx.tmpl and generate a "default.conf" like so: docker-gen nginx.tmpl default.conf The only way I saw people pass parameters to a template is with "environment variables":

{{ range $myvar, $containers := groupByMulti $ "Env.MYENVVAR" "," }}
	#I wanna print this: {{ $myvar }}
{{ end }}

My goal is to modify the "hostsList.csv" to load hosts on the fly while the container is running and compose my default.conf with new hosts.

But Docker is setup in a way that environment variables are set in stones... I can't find how to modify them once the container run.

Is there another way to pass parameters to the template other than environment variables!?

Something like docker-gen nginx.tmpl default.conf -params MYVARLIST="111111.com,22222.com,3333.com" Or at least How can I modify the environment variables at runtime? -_-"

Thank you for your time! :D

FractalMind avatar Mar 15 '18 21:03 FractalMind

I think something like this can work?

template:

{{ .Env.MYVARLIST }}

command:

MYVARLIST="111,222,333" docker-gen my.tmpl

gingerlime avatar Jun 30 '18 09:06 gingerlime