Changing Docker Services to use Host Networking

Modified on: Mon, 28 Jun, 2021 at 2:07 AM

Ideally the iTDS server and transform server should either be running on separate servers that have their own IP addresses or both run with Docker so that they can communicate with Docker's internal routing.

In some cases however, you may have the transform server running on the same host machine as the iTDS is running with Docker, and would like to proxy transforms to "localhost".

The problem with this setup is that the Docker containers run in an isolated environment, and cannot access services running on the host machine.

This can be solved by changing the docker containers to use Host networking.

It is possible to switch the servers to run using "network_mode: host" so that services running in the Docker containers can also access services running on the host machine. 

Warning: Switching to host networking, removes the isolated Docker network and can expose services running in the Docker container that were previously isolated.

We can create a new file "custom-itds.yml" which contains the customization needed to run the iTDS in host networking mode. The file should have the following contents:

version: '3'
      network_mode: "host"

      network_mode: "host"

This will allow the iTDS to access services running on the host machine. Unfortunately this will break the communication between the "itdsphp" container and the "itdsdb" containers. In order to fix this, you will need to add the following line to the "/etc/hosts" file on the host machine.

itdsdb localhost

This should be all the changes required to allow communication between the iTDS and a local transform server. You can run the server using the following command:

docker-compose -f itds.yml -f custom-itds.yml up

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.