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.

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="example.com:"$(getent hosts example.com | 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 dns.example.com | awk '{ print $1 }') --rm -ti imagename command