Mysql in Docker Compose is not taking enviroment variables

awesomemypro

This is my docker-compose.yml file, which has the environment variables specified (root username, password etc). However, when I run "docker-compose up", it is saying that MySQL is initializing with empty password!

Why? Is there a workaround?

This is the docker-compose.yml

version: '3.3'

services:
  db:
    image: mysql:5.7
          #build: sqldocker
    ports:
           -  "3306:3306"
    environment:
           - MYSQL_ROOT_PASSWORD=123456
           - MYSQL_DATABASE=testdb
           - MYSQL_USER=root
           - MYSQL_PASSWORD=123456
             # volumes:
            # - my-datavolume:/var/lib/mysql
    healthcheck:
           test: ["CMD", "mysqladmin", "ping"]
           timeout: 20s
           retries: 10
    restart: always
  backendserver:
    build: ./docker-demo-backend/
    ports:
           - "8080:8080"
    links:
           - "db"
    depends_on:
           - "db"
             # restart: always
  frontend:
    build: ./docker-demo-frontend/frontcrud
    links:
           - "backendserver"
    depends_on:
           - "backendserver"
    ports:
           - "80:80"
EchoMike444

When you used this image mysql/5.7 , the startup is split into 2 steps .

The first step is to do the init of the db and you have this message

2019-11-05T15:01:23.167671Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

But just after the DB is stopped , and restarted . and you don't have anymore the warning .

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related