This is more a general question for how to connect to local services through Docker. There's a similar question in a Github issue here that doesn't seem to have any resolution. What I'm really looking for is to be able to do development locally against my local development MySQL server, then once I'm ready to deploy, to test locally against a newly created deploy candidate docker image.
Ideally, both get settings from the same place as well, so I could put mysql_server: host_ip
. This seems like a typical use case. Is anything like this currently possible?
I'm using Boot2Docker specifically with MySQL server running on my host mac's OS X Yosemite NOT in a container. Would be cool to have a more general answer for future readers though.
On a mac with boot2docker, you can use homebrew's default mysql/mariadb settings by adding the Mac OS Host.
This worked for me (with, what I believe, are default settings).
To help with several of the additional questions and the main post I would like to link to a repo I have been managing to manage my local development. I have stopped trying to run any service for my development directly on OS X and use Docker containers as they are the exact same running on production and my environments can be matched and streamlined.
This repo consists of a web server, database server and a data container to load the MySQL databases.
I have and will continue to support this repo and have recently upgraded the documentation to make it turn key for other developer.
Docker Repo on GitHub
The Docker CLI docs give this solution (which assumes you are running on a Linux host with ):
Then the name
docker
inside the container will map to the host's IP address. For your case, you could usedocker run --add-host=mysql_server:$(hostip) ...
If using Boot2Docker, it sets up a mapping to the host at a predefined address, so on that platform the equivalent to the above is just the one command: