Check out example codes for "docker ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)". It will help you in understanding the concepts better.

Code Example 1

# This seems to work... Your milage may vary...

% docker run --rm -d -e MYSQL_ROOT_PASSWORD=pass -p 3325:3306 --name mysql_test mysql:5.7

% mysql -uroot -ppass -h127.0.0.1 -P3325

Learn ReactJs, React Native from akashmittal.com