Docker Community Forums

Share and learn in the Docker community.

Docker hostname does not resolve : host.docker.internal


(Spkellydev) #1

Hello, I’m receive some help for an issue I’m having where the host.docker.internal name does not resolve.
I’m able to make GET requests and respond through NGINX, but when I make a POST request to my server,

 host.docker.internal: Name does not resolve
server_1     | 17:57:19.158 [nioEventLoopGroup-41-1] WARN  com.coso.server.HttpMessageHandler - returning error 500:
server_1     | java.net.UnknownHostException: host.docker.internal: Name does not resolve

I am running my docker containers through an Ubuntu/xenial64 Vagrant box on windows 10. I have 3 images that I’m running through docker-compose.

docker-compose.yml

version: '3'

services:
  server:
    image: "coso20-server:latest"
    ports:
     - "8082:8082"
     - "9043:9043"
  nginx:
    image: "coso20-nginx:latest"
    ports:
    - "8080:80"
  cassandra:
    image: "cassandra:3.11.3"
    ports:
         - "9042:9042"

I’m able to see that all the ports are bound to localhost where I asked them to.

vagrant@ubuntu-xenial:/vagrant/com/coso/coso20-docker-images/coso-insights-server/dev$ docker ps
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                                                       NAMES
5ea12e50c6aa        coso20-server:latest   "/usr/bin/java -ja..."   6 seconds ago       Up 3 seconds        0.0.0.0:8082->8082/tcp, 0.0.0.0:9043->9043/tcp              dev_server_1
191d49169a46        cassandra:3.11.3       "docker-entrypoint..."   18 minutes ago      Up 4 seconds        7000-7001/tcp, 7199/tcp, 9160/tcp, 0.0.0.0:9042->9042/tcp   dev_cassandra_1
da33b4a3d8b5        coso20-nginx:latest    "nginx -g 'daemon ..."   18 minutes ago      Up 4 seconds        0.0.0.0:8080->80/tcp                                        dev_nginx_1


cat /etc/hosts
127.0.0.1       localhost ubuntu-xenial

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost   ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
127.0.1.1       ubuntu-xenial   ubuntu-xenial
127.0.0.1       host.docker.internal

My IPs are not publicly available through my company IP, is there something I should be doing different?

Thank you!