Sobes.tech
Junior — Middle

Is it possible to manage DNS settings for a container through Docker CLI commands?

sobes.tech AI

Answer from AI

Yes, DNS settings for a container can be managed through the Docker CLI when starting a container using the --dns option.

Example command:

docker run --dns 8.8.8.8 --dns 8.8.4.4 my_image

Here, the container will use the specified DNS servers (Google DNS) instead of the default system ones.

You can also specify additional parameters, such as --dns-search for setting domain suffixes.

Thus, DNS for individual containers can be flexibly configured via the Docker CLI without changing the global host settings.