Template for a seeded dockerized MySQL database using Docker Compose
Main goal of this template is to provide an easy way to setup a seeded database from an existing database for local testing and development.
Make sure you have Docker Desktop and Docker Compose installed.
To create and start the container:
To start in detached mode:
docker-compose up -d
Since this uses the
MYSQL_RANDOM_ROOT_PASSWORDenv variable, you can get the generated password by searching
GENERATED ROOT PASSWORDin the logs. If detached mode is used, you can use Docker Desktop to view the logs of the created container.
Place your database dump inside the
This config uses the
mysql:latest image, but you can change it. See the supported tags here.
This config uses the default port of
3306 but you can change the
XXXX:3306 with whatever you want. You might want to provide a different port if there's already a running MySQL Server instance on your machine.
This config only uses the
MYSQL_RANDOM_ROOT_PASSWORD, but if you want to specify your own password, replace it with
Other environment variables can be found here.
MYSQL_PASSWORDwill conflict with this seeded database setup.