-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create host.rancher-desktop.internal and host.docker.internal aliases #1000
Conversation
as symbolic names to access a service running on the host from inside the VM. Signed-off-by: Jan Dubois <[email protected]>
mode: system | ||
script: | | ||
#!/bin/sh | ||
sed -i 's/host.lima.internal.*/host.lima.internal host.rancher-desktop.internal host.docker.internal/' /etc/hosts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we capture the rest of the line in a \(.*\)
group and echo it out? Since the line to change comes from the lima-vm
repo seems like we should be more flexible to changes there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we capture the rest of the line in a (.*) group and echo it out?
No, I'm intentionally discarding it. The changes we make are persisted, so we would append the additional names over and over on each reboot otherwise.
If Lima ever adds more than one name to that line, then we have to adapt. But most likely Lima will generate additional lines if/when it wants to define more aliases for the gateway address...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with a note about possibly dropping entries.
@jandubois Hi! What about Windows? Is |
@jandubois I see. Maybe my code will be useful somehow. I have small workaround for Windows (powershell script): [updated] $ip = Get-NetIPAddress -AddressFamily IPv4 -InterfaceIndex $(Get-NetConnectionProfile | Select-Object -ExpandProperty InterfaceIndex) | Select-Object -ExpandProperty IPAddress;
$command = "nerdctl exec container_name /bin/sh -c `"echo " + $ip + " host.docker.internal >> /etc/hosts`"";
invoke-expression $command This tiny script takes IP from Windows and add one line to the end of |
@djfoxer Thank you for sharing! I've linked to it from the other issue, so whoever will work on it sees it. |
@jandubois Great! I will track this issue. |
Hmmm... what's different about my version of PowerShell and yours, @djfoxer ? First I got that "var keyword is not supported", then some missing line terminator stuff, presumably because of the kinds of quotes used. Still trying to work that out... |
First command also doesn't seem to produce the same IPs that
does. Ahh, this does: Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias "vEthernet (WSL)" | Select-Object -ExpandProperty IPAddress |
Sorry, I probably copied wrong code, my current version: $ip = Get-NetIPAddress -AddressFamily IPv4 -InterfaceIndex $(Get-NetConnectionProfile | Select-Object -ExpandProperty InterfaceIndex) | Select-Object -ExpandProperty IPAddress;
$command = "nerdctl exec container_name /bin/sh -c `"echo " + $ip + " host.docker.internal >> /etc/hosts`"";
invoke-expression $command I will update my comment. |
When I SSH to |
No, this is not working because the built-in resolver in Lima doesn't run inside the VM, it runs on the host to be able to resolve names from VPN etc. This will be fixed by lima-vm/lima#622 (so that Rancher Desktop can add these static names to the lima config). A workaround would be to add the settings to
The names will only work inside the VM and the containers, not on the host. But the |
as symbolic names to access a service running on the host from inside the VM.
Implements #893 for Linux and macOS