Prequisite
- Docker installed
- mysql client on the host machine is installed / Use Java client program to connect
Step 1
Download mysql image from docker central
docker pull mysql
Step 2
Check in docker whether image is available
docker image ls
Step 3
Run the docker container command, which will create container and start it.
The -p options will expose the port 3306 of mysql running inside the container to be accessibkle by host machine
docker run --detach --name=mysql --env="MYSQL_ROOT_PASSWORD=root" -p 127.0.0.1:3307:3306 mysql
Step 4
Check whether mysql Service Started. The container will be shown.
docker ps
Step 5
Connect mysql from docker host machine
mysql -uroot -proot -h127.0.0.1 --port=3307