Skip to content

Support port forwarding on both 127.0.0.1 and ::1 #1330

@encounter

Description

@encounter

Description

As of now, the default port forwarding doesn't properly forward on both IPv4 (127.0.0.1) and IPv6 (::1) interfaces:

➜ 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:

- 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions