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
Post a Comment