Two MySQL docker container

Viewed 123

I have a server that already run a MySQL server container on port 3306:3306 (build from a docker-compose.yml file)

I would like to run another MySQL container on port 3307:3306 from another docker-compose.yml. The problem is that for the second container the MYSQL_ROOT_PASSWORD is never set and I got an access denied.

Both containers are targeting different volumes.

Is it possible to run two MySQL container from two different docker-compose.yml file on the same server?

2 Answers

You are able to run 2 instances of MySQL on the same host and they don't interfere with each other.

What I think is causing your issue is that the environment variable MYSQL_ROOT_PASSWORD (and other environment variables) is only used when the container is started witout an existing database. If a database already exists, then the root password stored in the database is used.

You need to find out what root password was set when the database was created and use that.

The problem is solved.

docker-compose.yml doesn't accept env variable with the char $. To solve it we must escape the char like this : $$.

Thanks for your help guys.

Related