I have installed Ubuntu using virtual box and also install apt, docker and docker-compose inside it. Now I want to create MySQL database using docker-compose.yml In which, i defined MySQL configuration including imported database file. When i execute following command it install MySQL but not create database.
sudo docker-compose up -d --force-recreate --build
docker-compose.yml
mysql:
image: "mysql:5.7"
network_mode: "bridge"
volumes:
- ${DATA_ROOT}/mysql:/var/lib/mysql
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
environment:
- MYSQL_ROOT_PASSWORD=${ENV_PASSWORD}
- MYSQL_USER="${ENV_USER}"
- MYSQL_PASSWORD="${ENV_PASSWORD}"
- MYSQL_PORT_3306_TCP_ADDR=0.0.0.0
- MYSQL_PORT_3306_TCP_PORT=3306
command:
- --user=root
- --max_allowed_packet=500M
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --max_connections=250
- --default-authentication-plugin=mysql_native_password
ports:
- "3306:3306"
Also in some cases it allow me to create first time but when i remove whole image and volume in docker and try to recreate again then it given same issue.
I suppose there is some pre-installed file which restrict me to recreate it.(It's just my assumption)