1

I have a ubuntu container running but I cannot wget the localhost that is running my docker image.

For example, I use a lenovo laptop that runs docker. I then log into my laptop to start and run a ubuntu container. When I ssh into the ubuntu container I am not able to wget localhost url's. Is there a way to connect containers to localhost? Also how many ways can you connect to localhost via a docker container.

This is the error message I get when I wget

root@090cdf22ac53:/openchain# wget 127.0.0.1:8090
converted 'http://127.0.0.1:8090' (ANSI_X3.4-1968) -> 
'http://127.0.0.1:8090' (UTF-8)
--2017-09-01 04:41:22--  http://127.0.0.1:8090/
Connecting to 127.0.0.1:8090... failed: Connection refused.

Thanks in advance, all the questions similar to this do not answer my question.

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
Max Copley
  • 430
  • 3
  • 15

1 Answers1

1

Docker for mac recently gained a docker.for.mac.localhost (17.06).

But for Windows, you might try some of the options detailed in "How to get the IP address of the docker host from inside a docker container", that is at least:

 run --env <key>=<value>

Passing the IP when running your container is one simple way.

 run -e "DOCKER_HOST=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')"

Or, from "Insert Docker parent host ip into container's hosts file"

docker run --add-host=dockerhost:`docker network inspect \
--format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge` [IMAGE]
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250