Connecting Docker Host Services to a Docker Container
Dockers are good way to deploy applications with the thoughts of scalability and management; however, there are some instance where a deployed application needs to use a host service such as MySQL. Using Host Networking The first way to allow for a docker to use host services is to make the docker share the networking stack with the docker host, aka giving the docker the keys to the kingdom. This is done by adding --net="host" option to the docker run command. By using this option any ports opened on the docker container will also be opened on the docker host machine as well. Using Bridged Networking The second way to allow a docker to use host services is to inject the docker host bridge adapater into the docker's /etc/hosts file. This means we will be using DNS lookup to connect to the host services. For this I will be using a MySQL service running on the host as an example but other services can be substituted. First we need to update the MySQL co...