I faced the same issue. host.docker.internal
is available on identity, solr, but is not available on cm, sql containers.
You have a few options:
- You can use ngrok
- You can update your container manually by running this script:
# host.docker.internal is not available on CM, so we need to add it manually
$containerId = docker ps --filter ancestor=jss_astro-xm1-cm --format "{{.ID}}"
$ip = Get-NetIPAddress | Where-Object -FilterScript {$_.IPAddress.StartsWith("192")}
$ipAddress = $ip.IPAddress
Write-Host "Adding DNS record to container $containerId. Host: host.docker.internal. IP: $ipAddress"
$command = "'$ipAddress host.docker.internal' | Out-File -Append -Encoding ASCII -FilePath '$($Env:windir)\system32\drivers\etc\hosts'"
docker exec -it $containerId powershell $command
This script will add a record to the CM container hosts
file. And point host.docker.internal
to your host IP address.
P.S.
I expected that it should be fixed in Docker 4.19, according to release notes: "Reverted to fully patching etc/hosts on Windows (includes host.docker.internal and gateway.docker.internal again). For WSL, this behavior is controlled by a new setting in the General tab. Fixes docker/for-win#13388 and docker/for-win#13398."
But the issue is still there. And it requires deeper investigation: why does it work in the Identity container but fail on CM?