Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass parameters into template!? #280

Open
FractalMind opened this issue Mar 15, 2018 · 1 comment
Open

How to pass parameters into template!? #280

FractalMind opened this issue Mar 15, 2018 · 1 comment

Comments

@FractalMind
Copy link

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

@gingerlime
Copy link

I think something like this can work?

template:

{{ .Env.MYVARLIST }}

command:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants