Support port forwarding on both 127.0.0.1 and ::1
- Dominant language
- Go
- Stars
- 21.9k
- Forks
- 957
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 53
Description
### Description
As of now, the default port forwarding doesn't properly forward on both IPv4 (127.0.0.1) and IPv6 (::1) interfaces:
```sh
➜ docker run --name nginx -p 80:80 -d nginx
# note that docker is forwarding on both 0.0.0.0 and ::
➜ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
68a055ac7e3f nginx "/docker-entrypoint.…" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp nginx
➜ curl -Ss "http://127.0.0.1" -o /dev/null && echo ok
ok
➜ curl -Ss "http://[::1]" -o /dev/null && echo ok
curl: (7) Failed to connect to ::1 port 80 after 2 ms: Couldn\'t connect to server
➜ limactl shell docker curl -Ss "http://127.0.0.1" -o /dev/null && echo ok
ok
➜ limactl shell docker curl -Ss "http://[::1]" -o /dev/null && echo ok
ok
```
The default rule isn't expressive enough to accomplish this:
```yml
- guestIP: "127.0.0.1" # matches bind addresses "0.0.0.0", "::", and "::1"
hostIP: "127.0.0.1" # only forwards on IPv4
```
I would expect the default rule to be:
- If 127.0.0.1 or 0.0.0.0, forward on 127.0.0.1
- If ::1 or ::, forward on ::1
Or is there already a combination of options to accomplish this?
Contributor guide
Assessment
This issue has not been assessed yet.