Configure DNS options in a container
You can specify
dns_options in the orchestration template of Container Service to specify the DNS server and DNS options for the container.
testdns: image: nginx dns: dns_options: - use-vc - no-tld-query
The preceding example configures the DNS server and DNS query option for the service container.
| Docker embeds a DNS server in each container for service discovery. The DNS server in the /etc/resolv.conf file of the container is the built-in DNS server 127.0.0.11 for Docker. Docker listens to DNS requests of built-in servers and forwards the DNS requests to the server configured by
Optimize DNS resolution
When requesting a domain name, the DNS resolution might time out or fail, which causes the website to become inaccessible. The operating system generally enables the
nscd service as the DNS cache to avoid DNS resolution failure. However, the
nscd service is generally not configured in container images. You can install the
nscd service on the container that you often perform DNS resolution to optimize DNS resolution in the container.
nscd software package. Then, when the container is started, start the
nscd service first and then start your processes.
FROM registry.aliyuncs.com/acs/ubuntu RUN apt-get update && apt-get install -y nscd && rm -rf /var/lib/apt/lists/* CMD service nscd start; bash