DEV Community

Jakob Attkinson
Jakob Attkinson

Posted on

How to create 2 MySQL DBs in a single container?

Disclaimer: my Docker knowledge is non-existent. I only hack things together whenever I need something from a test project. In this particular case, I hit a wall since I'm not sure what I'm doing.

I am playing with some NodeJS apps, and in order to set up a quick database for my Windows machine, I use the following command:

docker run \
    --detach \
    --env MYSQL_ROOT_PASSWORD=something \
    --env MYSQL_USER=something_else \
    --env MYSQL_PASSWORD=something_new\
    --env MYSQL_DATABASE=something_name \
    --name some_other_name \
    --publish \
    --volume "C:\Database":/var/lib/mysql \
Enter fullscreen mode Exit fullscreen mode

This all works great. I get a fast container that I can just docker compose start from Docker for Windows and all is great.

However, I hit a wall now because I am trying to get a second database. Basically, a clone of the first one, with a different name.

The purpose of the secondary database is to have a dedicated DB for tests. But I'd like it to be in the same docker container, and ideally part of the same script.

Is this even possible? Any suggestions on how I could achieve this?

Top comments (0)