Building docker image with host network aka –net=host

There is no option to provide the net as param while building the docker images.
So the container doesn’t have internet from inside.
and is common to get this kind of errors

One (stupid) solution is to put in the Docker file

Another is to help Docker with the networking.

Here is a solution is pointed here

And also to configure docker to use a dns server as pointed here

Docker official doc gives instruments to Configure a DNS server for use by Docker

Open the /etc/default/docker file for editing.

Add a setting for Docker.

Replace 8.8.8.8 with a local DNS server such as 192.168.1.1. You can also specify multiple DNS servers. Separated them with spaces, for example:

–dns 8.8.8.8 –dns 192.168.1.1

Warning: If you’re doing this on a laptop which connects to various networks, make sure to choose a public DNS server.

ps: nm-tool can be used to check local host DNS server

Save and close the file.

Restart the Docker daemon.