Docker - Redirect DNS to another DNS

0

Hello,

I'm migrating a very old system made in PHP 5.2, however it does not have 1 file for database configuration, so all connections to the database are made locally in all files, which would be almost impossible to change manually.

I thought of creating a docker container with the same conditions as the old machine, but the DNS for the connection to the database will be modified after the migration.

Is it possible to bind from 1 DNS to another? Ex: Anytime a call is made to DNS dbmobile.example.com does it redirect to db.example.com?

    
asked by anonymous 20.06.2017 / 15:43

1 answer

1

Yes, there are some network layer configuration parameters that make this type of task trivial. I'll take the docker run as a base, but whatever you say is available in docker create and also in docker-compose.

--dns | allows you to tell the container what dns's it will use.

--add-host | add a line in / etc / hosts (host: IP), I believe this is the best alternative for you.

These settings are available in the same way in docker create and docker run, and a bit differently in docker-compose.yml.

Below is a link to the official documentation that explains these points.

docker run reference / network-settings

    
22.06.2017 / 10:28