First and foremost, please refrain from simply linking to another site with your already asked question. Everyone here is willing to help and it makes it easier for us to do so if all the relevant information exists in the thread.
Regarding your inability to connect to your MySQL container from your localhost, I was able to do so via the following:
docker run -e MYSQL_ROOT_PASSWORD=1234 -d -p 3306:3306 mysql:5.7.13 mysql -hlocalhost --protocol=TCP -uroot -p1234
I had to specify
--protocol=TCP otherwise MySQL attempts to use a local socket when connecting to localhost.
I also verified the connection works in Sequel Pro (though 127.0.0.1 had to be used over localhost).
Are you able to provide the diagnostic information provided by Docker for Mac?
I had to specify --protocol=TCP otherwise MySQL attempts to use a local socket when connecting to localhost.
Just FYI… You can use 127.0.0.1 as host to force MySQL to use TCP instead of a unix socket.
First, agreed. I meant to copy the question over from Stackoverflow but didn’t research whether I could copy over with the formatting.
$ docker run -e MYSQL_ROOT_PASSWORD=1234 -d -p 3306:3306 mysql:5.7.13 59c5cd3fda72246d75371922dac9bf7928c62e7ef9525476585895130ed4cc5f docker: Error response from daemon: driver failed programming external connectivity on endpoint big_hugle (5f259ae297244c6f7e0f9c453b5a0770a94039db64610022fab99eb1fb86306b): Error starting userland proxy: Failed to bind tcp 0.0.0.0:3306 address already in use.
You already have a MySQL container running on 3306. Try to connect to that one or kill it and start another.
Sorry, that’s not the problem. I
rm the older mysql container before attempting a new one.
docker ps -a does not show a
mysql container. Unless there’s some ghost container running under the removed
Toolbox version and I can’t see?
$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES in ~/work/bin $ docker run -e MYSQL_ROOT_PASSWORD=1234 -d -p 3306:3306 mysql:5.7.13 1ca7527550adf23c08080e39f0d6ee67255836d9adedbe3bd3796d66911a8243 docker: Error response from daemon: driver failed programming external connectivity on endpoint cocky_hopper (3ff759d4ba03e1953420bdb4a79acfe63e84eec8625ecd70641829b3048ba306): Error starting userland proxy: Failed to bind tcp 0.0.0.0:3306 address already in use.
Strange - do you have any remnant docker machines running that aren’t bound to anything? Have you tried existing Docker for Mac or even rebooting?
Solved. Turned out I had mysql running on my machine without my knowledge. It’s installed before Docker. The ToolBox Docker did not conflict with localhost, hence the problem did not show. Cleaned out mysql, boot2docker, VirtualBox. Now it’s working.