How to install MySQL in docker
Step 1: Pull mysql image MySQL can be of any version, but I chose 5.6 for setup $ sudo docker pull mysql/mysql-server:5.6 To pull the latest version $ sudo docker pull mysql/mysql-server Step 2: Start and config MySQL Copy IMAGE_ID $ sudo docker images To create and run MySQL first time $ sudo docker run --name mysql-5.6 -p 52000:3306 -e MYSQL_ROOT_PASSWORD=yourpassword -d IMAGE_ID Description --name => container name (can be anything) -p => external port : internal port -e => Environment variables (MYSQL_ROOT_PASSWORD) -d => Detached mode Step 3: Check the mysql process status $ sudo docker ps To enter the MySQL server $ sudo docker exec -it CONTAINER_ID bash $ mysql -uroot -pyourpassword After initial container creation to run MySQL copy the CONTAINER_ID $ sudo docker container ls -a To start $ sudo docker start CONTAINER_ID To connect using external MySQL first grant privileges $ mysql -P52000 -uroot -ppassword