Docker Community Forums

Share and learn in the Docker community.

Unresolved host name

Hi guys,

I’m trying to expose a container to the internet. I can make an HTTP request to an API inside docker using Postman, but when I try to call it from somewhere else (tructiepbongda) i get an “Unresolved host name” error. Any ideas on how to fix this? Any help is highly appretiated.

This error means that the hostname you are trying to connect to cannot be resolved to an IP address. … If you have verified that the hostname is correct, there may be a problem with your DNS server (or with your ISP’s DNS server, if you are a standalone user). It may be unable to resolve hostnames to IP addresses.

You have 2 options, if you are running this container interactively. First is to add resolve only for a specific host

docker run -v $(pwd):/code --user $(id -u):$(id -g) --add-host=""$(getent hosts | awk '{ print $1 }')"" --rm -ti imagename command

Or add your own DNS to the container

docker run -v $(pwd):/code --user $(id -u):$(id -g) --dns=$(getent hosts | awk '{ print $1 }') --rm -ti imagename command