Docker-撰写的Percona / Mysql映像未初始化环境变量

时间:2019-07-09 20:54:23

标签: docker docker-compose percona

我根据Percona官方Docker在docker-compose.yml中声明了env变量:

version: "3.5"

#### Creating Services ##### 
services: 

  ##### Database Service #####     
  db:
    image: percona:latest
    container_name: percona_db
    restart: always
    ports:
     - 3306:3306 
    environment:
     # TIMEDATE
     TZ: GMT+7
     # MYSQL VARIABLE
     MYSQL_ROOT_PASSWORD: password
#     MYSQL_ROOT_HOST: '%'
     MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
     MYSQL_DATABASE: test_db
     MYSQL_USER: user
     MYSQL_PASSWORD: password
    volumes:
    # Volumes db -> /var/lib/mysql 
    # - db:/var/lib/mysql
    # Volumes ./data/mysql -> /var/lib/mysql 
     - ./data:/var/lib/mysql
    # Volumes /etc/timezone & /etc/localtime
     - /etc/timezone:/etc/timezone
     - /etc/localtime:/etc/localtime
    # Volumes config/mysql/my.cnf:/etc/mysql/my.cnf
     - ./config/mysql/my.cnf:/etc/mysql/my.cnf
    # Volumes config/mysql/mysqltuner:/
     - ./config/mysql/mysqltuner:/mysqltuner
    # Volumes bin/export_databases.sh:/backup/
     #- ./config/mysql/export_databases.sh:/backup/export_databases.sh
    # Volumes config/mysql/.my.cnf.sh:/bin/
     - ./config/mysql/.my.cnf:/home/mysql/.my.cnf
    # Volumes ./www:/www
     - ./backup-data:/backup
    networks: 
     - internal

  ##### Redis Cache #####
  redis_cache:
    image: redis
    container_name: redis_cache
    restart: always
    networks: 
     - internal

##### Creating Volumes #####
volumes: 
  db:
##### Creating Networks #####
networks: 
  internal:
    name: internal

先做

docker-compose up -d

我已经做了docker-compose down -v并删除了所有已安装的卷文件夹

问题是mysql不会创建mysql数据库,用户,也不会为root和user分配密码。

0 个答案:

没有答案