This might be a really weird or edge case scenario, but what If we need to access host service(s) from inside a Docker container. For instance, we already have configured and running a service on the dev host machine and kinda lazy to Dockerize it.
Docker supports a
host-gateway reference to the host’s gateway. This will allow us to map a host endpoint to the
From the CLI:
docker run --rm -it --add-host host.docker.internal:host-gateway alpine:latest
services: test_service: extra_hosts: - host.docker.internal:host-gateway
TL;DR add additional host entry
host.docker.internal:host-gateway. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.