The second way is to install a DNS server in the local network and map the domain to local IP address, adding the {local-IP} yourdomain.com A record to it (here {local-IP} is the local IP address of the server and yourdomain.com is the server domain name).
This DNS server must be the first in the list of DNS servers in the /etc/resolv.conf file of the host machine.
According to Docker documentation, in the absence of the --dns=IP_ADDRESS..., --dns-search=DOMAIN..., or --dns-opt=OPTION... options, Docker makes each container's /etc/resolv.conf look like the /etc/resolv.conf of the host machine where the docker daemon runs.