Docker Compose - MySQL - MYSQL_ROOT_PASSWORD

Mahadevan G :

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

Neo Anderson :

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

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

MYSQL_ROOT_PASSWORD is set but getting "Access denied for user 'root'@'localhost' (using password: YES)" in docker container

Docker-compose mysql does not seem to recognize environment variable MYSQL_RANDOM_ROOT_PASSWORD

Docker-compose mysql environment difference between PASSWORD and ROOT_PASSWORD

MySql 8.0.0 and Docker compose problems

NodeJS + Mysql with Docker Compose 2

Docker Compose mysql import .sql

docker-compose rails with mysql

How to containerize MySQL using Docker for Docker Compose?

Connecting Python and MySQL in docker / docker-compose

docker-compose secrets MYSQL_ROOT_PASSWORD_FILE work correctly but DB_PASSWORD result empty string

Docker compose does not create users ,password and database for mysql8

docker-compose: Unable to connect app service to mysql database, receive "Error: Access denied for user 'root'@'localhost' (using password: YES)

mySQL init scripts not running with docker-compose

Docker-Compose persistent data MySQL

Correctly using mysql commands in docker-compose?

docker-compose up error for django and mysql

docker-compose wordpress mysql connection refused

Run MySQL on Port 3307 Using Docker Compose

Connect tomcat and mysql in docker-compose

Mysql in Docker Compose is not taking enviroment variables

Docker compose push to registry with Spring and mysql image

docker-compose unable to connect mysql

MySQL in docker-compose -- access denied

Docker-compose container connection to MySql not working

Docker compose mysql reachable on port 3306

docker-compose linking mysql and php containers

Set MySQL variables via argument in Docker Compose

Docker-compose for nginx, php, mysql, golang

Docker Compose with PHP, MySQL, nginx connection issue