DEV Community

Jakob Attkinson
Jakob Attkinson

Posted on

4 3

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 127.0.0.1:1234:1234 \
    --volume "C:\Database":/var/lib/mysql \
    mysql:8.0
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?

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay