I had to add 2 DNS entries 8.8.8.8
and 8.8.4.4
and after that my image is not able to connect to Xdebug because host.docker.internal
is not being recognized inside my image anymore.
curl: (6) Could not resolve host: host.docker.internal
(executed inside the docker image)
php:
build:
context: docker
dockerfile: php.dockerfile
container_name: php-site
volumes:
- .:/var/www/html
ports:
- "9000:9000"
networks:
- laravel
dns:
- 8.8.8.8
- 8.8.4.4
When I remove these DNS entries and reload the container then everything works fine.
I feel like the solution is not that difficult to find, but I'm not a networking expert, so I ask you for help please.
CodePudding user response:
architecturally, container solutions all run internal DNS services which forward to upstream DNS providers like 8.8.8.8, if you directly set the DNS to resolve at 8.8.8.8, it won't be "proxied" through internal DNS, which is responsible for resolving docker.internal, etc.
the upstream is set via /etc/resolv.conf, so it's easier if you just update system DNS to 8.8.8.8.