Windows 10 Professional, Enterprise, or Server 2016 with a CPU supporting virtualization features OR Mac OSX 10.11+
When running in Windows, you'll need to run an Administrator command prompt or powershell prompt for the docker commands. You can do this by right-clicking the Windows icon in the taskbar, then selecting 'Command Prompt (Admin)' or 'Windows Powershell (Admin)'.
Setting up a local MySQL test environment
Sign up for Docker (making note of your credentials) and download Docker for Desktop
Once docker is installed, run the following command to download the MySQL container template.
docker pull mysql:8.0.16
Run the following command to create a MySQL container, replacing 'my-secret-pw' with an arbitrary password to connect to MySQL with.
docker run --name wellness-mysql --publish 3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:8.0.16
Breakdown of the command
'docker run': Runs a process in an isolated container.
'--name': Designates the container's name.
'--publish': Maps an external port to an internal port in the container. Without this, the container will have no external access.
'-e': Allows you to set environmental variables published by the container. The environmental variables are created during container template creation.
'-d': Daemonizes the container, causing it to run as a background process.
'mysql:8.0.16': Defines the container template to use for the container.
Run the command docker ps -a to list out all the containers on your system. Verify that the 'wellness-mysql' containers STATUS is listed as up.
Start MySQL Workbench, click on 'database>manage connections...'
Give Connection name, and set other inputs based on variables entered for docker run command. For above example Set 'Hostname' to 'localhost', 'Port' to '3306', 'Username' to 'root', and 'password' to 'my-secret-pw'
Click 'Test Connection' to check if successful.
Connect to database, click on 'database>connect to database'
Select from stored connections and hit 'ok'
Now Create a new schema in the connected server. Schema is synonymous for database in Mysql workbench.
Notes
General notes
docker ps -a lists of all the containers on your system.
docker stop wellness-mysql will stop the container named 'wellness-mysql'.
docker start wellness-mysql will start the container named 'wellness-mysql'.
docker rm wellness-mysql will delete the container names 'wellness-mysql' if it is already stopped.
docker image ls will list the container templates you've downloaded. You can use these to create new containers with docker run.
On Windows, Docker sets up a Hyper-V virtual machine on install to run docker containers on by default.
After Hyper-V is enabled, VirtualBox no longer works, but any VirtualBox VM images remain. The inverse is also true. Installing VirtualBox after Hyper-V will make any Hyper-V/Docker images no longer work.
For OSX, VirtualBox prior to version 4.3.30 must NOT be installed (it is incompatible with Docker for Mac). If you have a newer version of VirtualBox installed, itโs fine.