Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Working with MySQL within Docker is extremely straightforward. 

Begin by downloading MySQL from hub.docker using the pull command docker pull mysql

Code Block
languagebash
titleRun the command
docker run -p 3306:3306 --name mysql-populated -e MYSQL_ROOT_PASSWORD=<password> -d -v <path to share with container>:/root <image id>

In the command above replace the parameters shown with the values indicated

parametervalue
<password>memorable password, I keep it simple when developing
<path to share with container>

//c/Users/Selvyn/demo/vm_share/mysql

//c/Users/Selvyn/ must be the path to your account's home directory if you are using windows, or your home directory on Linux/Unix

The demo/vm_share/mysql can be any directory under your home folder

<image id>Should be the image id for mysql if you run docker images


Info
titleImportant

//c/ the drive letter must be lower case


Using the above table I use the following command

Code Block
languagebash
titleRun the command
docker run -p 3306:3306 --name mysql-populated -e MYSQL_ROOT_PASSWORD=ppp -d -v //c/Users/Selvyn/demo/vm_share/mysql:/root mysql-db-unpopulated:latest