简体   繁体   中英

Docker Compose - MySQL - MYSQL_ROOT_PASSWORD

Not able to start mysql container using docker-compose.yaml file, when I use '$' sign for the MYSQL_ROOT_PASSWORD.

I tried with the other special character '@' and it is starting up.

my docker-compose.yml file

version: '3.3'
services:
  database:
    container_name: mysql-dev2
    image: mysql:8.0
    volumes:
      - "./data/mysql-dev2:/var/lib/mysql-dev2-docker"
    # restart: always
    environment:
      MYSQL_DATABASE: mysqldb2
      MYSQL_ROOT_PASSWORD: Welcome123$
    ports:
      # <Port exposed> : < MySQL Port running inside container>
      - '3307:3306'
    expose:
      # Opens port 3307 on the container
      - '3307'
# Names our volume
volumes:
  mysql-dev2:
 The error which I am getting F:\\docker\\mysql-dev2>docker-compose up ERROR: Invalid interpolation format for "environment" option in service "database": "Welcome123$"

If I change the MYSQL_ROOT_PASSWORD to 'Welcome123@', the mysql instance is started running.

help me on this.

regards, Mahadevan.G

You can escape the $ if with a double $$ :

...
environment:
      MYSQL_DATABASE: mysqldb2
      MYSQL_ROOT_PASSWORD: Welcome123$$
...

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