Connect MySQL workbench with MySQL container I pulled MySQL container from Dockerhub and it is running on my macbook pro as you can see as follow

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
12cd3deaa3f0        mysql:latest        "/entrypoint.sh mysql"   47 hours ago        Up 10 minutes       3306/tcp            mysqldb


Then I downloaded the MySQL workbench and I tried to connect it with MySQL container, but it does not work. It shows connection error.   

Your connection attempt failed for user 'root' from your host to server at 192.168.99.102:3306:
Can't connect to MySQL server on '192.168.99.102' (60)


The IP from docker machine is 

docker-machine ip default
192.168.99.100


and the port from MySQL is 3306 as you can see above. 

To export MySQL port, I tried with the statement

docker run -d -P mysql:latest mysqldb


It does not work at all. What am I doing wrong?
It looks like you ran the container without setting the -p 3306:3306 parameter. Also, it seems that you mistyped the IP address in of the Hostname in MySQL Workbench. I recommend starting from scratch by following these instructions:


Run the mysql server. (Change the password admin to anything you want)


docker run -e MYSQL_ROOT_PASSWORD=admin --name mysql -d -p=3306:3306 mysql


get the IP address of the default docker virtual machine by running 


docker-machine ip default


Copy the IP address that you'll get as the result of the previous command. (in your case, it should be 192.168.99.100)
Open MySQL Workbench and create a new connection. Paste the IP address that you copied into the "Hostname" field.


You should be all set now.