Docker container should not resolve DNS in Ubuntu 18.04

Docker container should not resolve DNS in Ubuntu 18.04
I want to access server with name from inside container
Am running a container with --dns flag with host’s DNS server IP
docker run -itd --dns 127.0.0.53 --name test_img

But from inside container am not able access google server

[root@0b86fa7dde50 scripts]# curl google.com
curl: (6) Could not resolve host: google.com; Unknown error
[root@0b86fa7dde50 scripts]#

Host DNS details:
root@rebaca# nslookup google.com
Server: 127.0.0.53
Address: 127.0.0.53#53

Non-authoritative answer:
Name: google.com
Address: 216.58.194.206
Name: google.com
Address: 2607:f8b0:4005:805::200e

without that --dns flag in docker run command, am bale to access google.com as because by default container is running with 8.8.8.8 dns server

But am not able to access my consul server with Domain name.

How would i access consul server and google server with domain names without adding details in /etc/hosts file

The lo interface inside the container, the one receiving IP packets destined to 127.0.0.53, is not the same lo interface of the docker host, i.e. outside the container. Try to connect to the dns server with the nc tool:

nc -v 127.0.0.53 53

If you see a message saying connection refused that would prove you can not reach the dns server. Instead, use the IP address assigned to the host ethernet (ow wifi) adapter.