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?
Best Answer
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:admin
to anything you want)docker run -e MYSQL_ROOT_PASSWORD=admin --name mysql -d -p=3306:3306 mysql
docker-machine ip default
You should be all set now.