简体   繁体   中英

Interpolation format error at MYSQL_PASSWORD in "db" service of docker-compose

As I try to start my containers with docker-compose up I am receiving the following error:

ERROR: Invalid interpolation format for "environment" option in service "db": "MYSQL_PASSWORD=..."

The provided password contains special characters(!, $, @, &, #). I believe that these ones are causing the problem.

Is there any way to provide the password like this in the docker-compose.yml ? How can I pass it to the service in a valid format?

The problem is the $ character in your MYSQL_PASSWORD environment variable. You should escape it by adding $ in front of the $ character : $$ . For example, if your password is !$@&# , you should write :

environment:
  - MYSQL_PASSWORD=!$$@&#

The best and secure way is to use docker secret with your password. Then put in compose MYSQL_PASSWORD_FILE=/run/secrets/your_secret_name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM