TLDR: just looking for the code? Skip to the end.
This document guides you through the setup of Docker and MySQL.
Why would you want to do it this way?
- Isolated environment. Need to upgrade from version 5.7 to 8.0 and are just developing locally? Previous configurations breaking your installation? Toss your old image and get a new one.
- Preparation for real world development. Local databases are typically for coding and testing. Developers don't normally run a live production database from their own machine. We just need a database we can quickly test and develop on. Docker is perfect for that.