Home > Net >  dollar sign in environment variable specified when launching docker container
dollar sign in environment variable specified when launching docker container

Time:06-30

I'm running redmine in a docker container. Within redmine I want to send email through smtp. To do that I need to set environment variables when launching the container, eg.:

docker run --name=redmine ... --env='SMTP_HOST=host.com' --env='[email protected]' --env='SMTP_PASS=$mypassword'

I didn't choose the password, and unfortunately it really starts with a dollar sign. If I just provide the password as is in the container the variable SMTP_PASS is empty, as there is no variable 'mypassword' defined. How to specify the password containing the $-sign?

CodePudding user response:

You can escape it with a backslash: --env='SMTP_PASS=\$mypassword'

CodePudding user response:

Screen

I'm sorry but i can't reproduce the issue. Look at the above screen and you can see that is possible use '$' character in envs value without escaping.

docker run --rm --env='PASSWD=$value' -ti redmine /bin/bash -c "env | grep PASSWD"
  • Related