Docker containers not able to resolve fqdn used in containers

I have docker containers in a RHEL 8 server. The server has not access to Internet and is in a corporate network. I have loaded docker containers to the server using the docker load command using .tar files of the modules. After loading the .tar files I am able to see the images using the -
sudo docker images command.
But when I try to see the running containers using - sudo docker ps -a, then it does not show any running containers.
I have added the host entry in the /etc/hosts file the fqdn and corresponding private IP.
On checking logs it says -
caused by: Container on the default network could not connect to fqdn:port
caused by: docker returned exit status: 1, stderr = One or more errors occurred. (Name does not resolve)

On running nslookup command in the server it gives:
nslookup fqdn
** server can’t find fqdn: NXDOMAIN

On running nc command it works fine and is able to resolve the fqdn to the private IP.

Please let me know how to resolve this issue.


Only exited containers, or no containers at all?

I assume this is done on the host? What is the host entry used for?

Why would you expect a dns lookup to know about entries in /etc/host?

no containers at all

Since the server has no connection to any public dns servers, I was trying to add fqdn and its private IP in the /etc/hosts file

I was not sure, I was thinking may be the local dns server can resolve the fqdn from the /etc/hosts file

It doesn’t work that way. Even though your host is able to use the entry from /etc/hosts ( e.g. for ping, curl), a tool that relies on querying a dns server won’t know anything about it.

I must admit, I still have no idea about what the actual situation is. The only things we know are that you are in an air-gapped environment, loaded images from tars into docker’s local image cache, and that you can’t see any running containers. And we know that you somehow have problems with dns, but don’t know why it’s relevant.

I am afraid you have to provide way more details than that. Please share the exact commands and outputs you received, so we actually understand things.

Docker load only loads the images from tar into the normal storage place, it does not run them.

Load an image or repository from a tar archive (even if compressed with gzip, bzip2, or xz) from a file or STDIN. It restores both images and tags.

So you need to run them like regular containers, then they should be able to be looked up.