Host cannot find Docker’s ip. How to fix it?

Asked

Viewed 973 times

0

The host is a MAC OS with Docker installed and a container with php and Xdebug configured.

I try to start a debug session in Intellij but it is not working.

My hypothesis is that since the host can’t find the Docker container, the IDE can’t find the container. Here is an example of how the Xdebug.

When I try to ping my host that’s what I find:

  1. Container IP => docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 64ad351e115f //Shows 172.17.0.2
  2. Container ping =>

inserir a descrição da imagem aqui Shows loss of 100%

How do I expose the container?

  • If I’m not mistaken, by default (unless you’ve configured it differently) containers run on isolated networks of your host, test with: Docker run -it <container-id-here> ping 172.17.0.2. Maybe the Expose also help you.

  • Tom I start the container with -p80:80 and -P9000:9000.

1 answer

1

Your machine won’t make it drip the container ip, because it is in another network (isolated), what you can do is map the container ports with your local machine. I don’t know how your debugging tool works, but if it needs an ip and a port, you would have to do so:

docker run --name <nome-do-container> -p 80:80 -p 9000:9000 <imagem:tag>

Then your software would access this container from your localhost like this:

localhost:80 ou locahost:9000

Browser other questions tagged

You are not signed in. Login or sign up in order to post.