Running MySQL inside docker

On a Cpanel Server with old version of PHP, one of the application require MySQL 5.6 to work. Since PHP version is no longer supported, updating MySQL using WHM will upgrade PHP to one of the supported versions, that may break existing sites. So i decided to install MySQL inside docker.

First create a folder for MySQL docker to store data.

Now run

Here i used “KqAtPd3BpyKjQ” as password, replace it with your password.

-p 3307:3306 -> tell docker to map port 3306 inside the docker container to port 3307 on host machine.

This will pull MySQL docker image and start it.

Once it finished download, you can check if its running with command

To connect to MySQL use

Auto Start on Boot

To start the container on boot, i added following to /etc/rc.local