Docker - Redirect DNS to another DNS

Asked

Viewed 296 times

0

Hello,

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

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

Is it possible to bind one DNS to another? Ex: Every time a call is made to dbmobile.exemplo.DNS it redirects to db.exemplo.com?

1 answer

2


Yes, there are some network layer configuration parameters that make this type of task trivial. I will base the Docker run, but everything you say is available in Docker create and also in Docker-Compose.

--dns | allows you to tell the container which dns it will use.

--add-host | adds 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 the Docker create and Docker run, and slightly different in the Docker-Compose.yml.

Below is the official documentation link that explains these points.

Docker run Reference / network-Settings

Browser other questions tagged

You are not signed in. Login or sign up in order to post.