Mysql: Unable to connect to mysql on 3306 from outside world

Created on 25 May 2016  路  15Comments  路  Source: docker-library/mysql

My docker container is up and running, it is linked to PhpMyAdmin (runs fine, is exposed to :80) and shows up into 'docker ps'.

However, when I telnet to 'hostname 3306', I'm unable to connect to the database.

What can I do to further debug this or to fix the installation?

I know this might be not a bug, but since I know of no other discussion platform I created this 'issue'.

Thanks in advance, if any additional information is needed, please ask for it.

FYI:
Running in Ubuntu on Azure. Port 3306 is open in the same way as port 80.
According to my Docker output, the mysql-server container should be exposed to :3306. It's not mentioning 127.0.0.1, so it should be public.

Most helpful comment

I have the same issue.

docker run -e MYSQL_ROOT_PASSWORD=blah -p 3306:3306 -d mysql:latest

running on my mac with docker beta, and I cannot connect to it from a normal Mysql gui client at all.

All 15 comments

Are these two containers running on one VM in Azure? Are you trying to access the mysql port from your local machine and is that remote VM configured on Azure to allow that port through the firewall?

Are these two containers running on one VM in Azure?

Yes

Are you trying to access the mysql port from your local machine

On Azure VM: telnet localhost 3306 connects
From local PC: telnet {IP} 3306 generates timeout

and is that remote VM configured on Azure to allow that port through the firewall?

The Azure VM with docker is configured to allow port 3306 inbound. I tried from several remote computers, all without outbound restrictions.

I am aware that this smells a lot like a firewall issue. The one thing I don't get though is that port 80 works perfectly (similar showup in docker ps/also opened in Azure) and I can access PhpMyAdmin (which can access MySql), but I can't access MySql directly from an external device.

If it is not a firewall issue then I would ask how you started the mysql container? Did you have a -p 3306:3306?

Yes I have.

Other clues:
From ubuntu:

telnet localhost 3306

Responding MySQL

telnet {Azure Remote IP} 3306

Not connecting..

I just read this somewhere else in the Azure Portal.

NOTE: By default, this deployment doesn't enable remote client connections to the Docker Engine. You can enable remote access while creating the virtual machine in Settings > Docker > Engine. To enable it after the virtual machine is created, refer to Running Docker with https.
This container will run on Ubuntu Server 15.10. Updates and patches for Ubuntu 15.10 will be available until July 2016.

Docker Engine is not the same as MySQL right?

No, not the same. That would be accessing docker itself on the VM with a docker client on your local machine. If the listening port shows up on the VM with netstat -ln | grep 3306 and you can hit mysql from your VM via localhost, then it still really feels like a firewall issue; maybe something in the Network Security Group?

I have the same issue.

docker run -e MYSQL_ROOT_PASSWORD=blah -p 3306:3306 -d mysql:latest

running on my mac with docker beta, and I cannot connect to it from a normal Mysql gui client at all.

"Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (2002)"

@billbuilder try using 127.0.0.1 instead of localhost.

I just ran into this running alpine in docker and adding mysql-client.
telnet -l user mydb.com 3306 timesout

Maybe you should add some inbound rules to Network Security Group on Azure, by default it only has port 22 open in order to stablish SSH sessions.

You can add a new inbound rule to add mysql standard port

same issue here. Only works if I map to another port, e.g. 8306:3306 ...

I retract my comment...just worked now...apparently mysql was not fully started yet.

You should also allow the connection on the VPC security group on Azure portal.

http://stackoverflow.com/a/40960992/837623

Given that this is confirmed to be an issue with runtime container configuration and not the image, I'm going to go ahead and close. :+1:

Was this page helpful?
0 / 5 - 0 ratings