mysql – Connect to local port from docker


On centos running mysql locally and installing a web server in docker compose with ubuntu 14.04. How can I connect from docker to mysql running locally on server?


I did similar with postgresql , you need:

  1. configure docker so that the bridge that it makes by default docker0 known ip address (I don’t remember the details, but maybe this is how docker is configured by default?)

  2. write in the config so that mysqld to using bind-address=

  3. Make sure mysqld starts later than docker – it depends on what you are using on the system. I had init.d + upstart , so I just added a bash loop like ifconfig | grep docker0

  4. It is possible to correct the iptables rules so that it does not chop packets (if the settings are not paranoid, then this step is usually not needed)

Everything can now be accessed from the container at to mysql

Scroll to Top