Run a local DNS container with auto-restart (--restart always) named "dns" (--name dns). It automatically load itself into /etc/resolv.conf host system machine (-v /etc/resolv.conf:/tmp/resolv.conf) and resolve Docker (-v /var/run/docker.sock:/var/run/docker.sock:ro) container's IPs with its name on .docker (-e DNS_DOMAIN=docker) domain name. Any container inside any network (-e NETWORK=auto) can be reached from your system using your browser, MySQL clients, FTP clients, SSH and any other kind of network protocol.
Run this on-liner command to execute DNS container:
docker run -d -v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /etc/resolv.conf:/tmp/resolv.conf \
-e NETWORK=auto \
-e DNS_DOMAIN=docker \
--name dns --restart always \
daaru/devdns:latest
NOTE: When you go offline or change WiFi network file are rewritten by system and you'll lose connection to DNS. Simply reload this container to fix this issue.
docker pull daaru/devdns:latest