You can specify
dns_options in the orchestration template of Container Service to specify the DNS server and DNS options for the container.
The preceding example configures the DNS server and DNS query option for the service container.
Note: Docker embeds a DNS server in each container for service discovery. The DNS server in the
/etc/resolv.conffile of the container is the built-in DNS server
127.0.0.11for Docker. Docker listens to DNS requests of built-in servers and forwards the DNS requests to the server configured by
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.
RUN apt-get update && apt-get install -y nscd && rm -rf /var/lib/apt/lists/*
CMD service nscd start; bash