Reputation: 69675
I am trying to set up two containers one running Python, and the other mysql.
This is my docker-compose.yml
file:
version: '3'
services:
python:
restart: always
build: ./budget/dockerfiles/python/
ports:
- "5000:5000"
links:
- db
depends_on:
- db
volumes:
- ./budget/:/app:z
entrypoint:
- python
- -u
- /app/run.py
db:
build: ./budget/dockerfiles/mysql/
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: database-name
MYSQL_USER: root
MYSQL_PASSWORD: password
volumes:
- ./Dump.sql:/db/Dump.sql:z
- ./Dump_Test.sql:/db/Dump_Test.sql:z
- ./big_fc.sql:/db/big_fc.sql:z
ports:
- "3306:3306"
However, when I run docker-compose up -d --build
, the containers are built, but the mysql container crashes. In the log, it says:
ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'%'
I wanted to try what this post suggests, but I cannot even enter the container since it is crashed. Can somebody tell me what I can do?
Upvotes: 44
Views: 23946
Reputation: 69675
According to this github issue, the problem is setting MYSQL_USER
to root
. It will fail to create the second user 'root'@'%'
since it will already exist in the users table.
Therefore, this can be solved by only setting MYSQL_ROOT_PASSWORD
, MYSQL_DATABASE
, and MYSQL_PASSWORD
in the docker-compose.yml
file.
Upvotes: 105