How to pass environment variable values into files in the docker container I'm trying to run -


let's have config file in docker container located here:

/opt/jboss/bin/config.xml

the config file looks this:

<database-password>$password</database-password> 

i want pass actual password in when go run docker container using "--env-file" argument.

this contents on env-file i'm passing in:

password=mypassword 

i understand variable=value syntax. "mypassword" value of password variable.

how docker know find specific file (/opt/jboss/bin/config.xml) variable , swap out? declaring variable correctly in config file? reason i'm having trouble finding information.

the short answer - won't necessarily. unless have mechanism rewrite config file host environment.

this pretty easy in shell script - can refer have done.

but xml file isn't "run" in sense, probably won't work.

as example - if want 'edit' xml, perl - you'll have install bit more stuff work:

perl -mxml::twig -e'xml::twig -> new ( twig_handlers => { database-password => sub { $_ -> set_text ( $env{password} ) } } ) -> parsefile_inplace("/opt/jboss/bin/config.xml")' 

(this need both perl , xml::twig installing, there may better options)


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -