-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
ipv6 addresses with square brackets cannot be used with the --add-host
option
#4648
ipv6 addresses with square brackets cannot be used with the --add-host
option
#4648
Comments
Thanks for reporting; can you try specifying the IP-address without square brackets? IPv6 addresses surrounded by square-brackets are commonly used for URLs, to prevent ambiguity if the IP-address is followed by a port ( I had a quick peek where this validation happens; This error comes from Lines 228 to 229 in b90a3d4
net.ParseIP() , which looks to only support bare IPv6 addresses without brackets; https://pkg.go.dev/net#ParseIP
We could relax validation on the client side, and strip the square brackets, but not sure if that's a good idea, as we wouldn't be able to support the same over the API as the daemon-side likely would run into the same issue (which may make things more confusing) /cc @akerouanton (in case you think we should accept this format here) |
One thing we should consider though is to use |
--add-host
option--add-host
option
Ahah, thank you @thaJeztah. This form does in-fact work:
But I strongly agree with your implication, that this form would make more sense:
|
Oh! And I just realized for some reason I completely glanced over your avatar and didn't recognize your handle; did you change it or do I just mis-remember? Either way: hope you're doing well! I don't think we met in person, but have interacted before (at least on urfave/cli).
Yes, I'm considering opening a pull-request for that. Using a colon ( Supporting the bracketed format ( |
I agree the current colon-based format is confusing and supporting square brackets would remove that confusion. We should definitely move away from that format. For the record, RFC 5952: A Recommendation for IPv6 Address Text Representation, section 6, is the only case where the use of square brackets are recommended. That's why
If we accept to do that, it's only due to the confusion created by the colon seperator we currently have on the CLI. So, I think this change should not slip into the deamon. And to keep it easy to move from the old, colon-based format to a new, equal-based format, we should support bracketed IP address in both IMO. I think that could be a good one for @robmry. |
I started looking at this one, and (fun, fun fun!) it looks like this is one of those examples where the UX became part of the API. The API takes the literal input from the CLI, and passes that as a Unfortunately, that means that we either need to
I also recall some discussions in the past on introducing custom DNS entries (the current One thing I DID notice is that |
I'll have a bash at this ... handling it in the CLI to avoid the compatibility problems, and permitting bracketed addresses. For now, to avoid surprising a user who's expecting to see the address they asked for, I won't use the canonical address returned by ValidateIPAddress() - but can easily change that if others disagree. |
Fixes docker#4648 Make it easier to specify IPv6 addresses in the '--add-host' option by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: --add-host=hostname:127.0.0.1 --add-host=hostname:::1 --add-host=hostname=::1 --add-host=hostname:[::1] To avoid compatibility problems, the CLI will replace an '=' separator with ':', and strip brackets, before sending the request to the API. Signed-off-by: Rob Murray <[email protected]>
The smallest / most narrowed change for now would probably be to accept both In the meantime we can already update the daemon side as well to accept both (for future) |
The change on my CLI clone (linked above) deals with For non-buildx, the option is handled by the same code as |
Arf, yes forgot about buildx. One more reason to have more of these in a proper sdk to allow easier re-use, but well get there eventually |
Fixes docker#4648 Make it easier to specify IPv6 addresses in the '--add-host' option by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: --add-host=hostname:127.0.0.1 --add-host=hostname:::1 --add-host=hostname=::1 --add-host=hostname:[::1] To avoid compatibility problems, the CLI will replace an '=' separator with ':', and strip brackets, before sending the request to the API. Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Make it easier to specify IPv6 addresses in the '--add-host' option by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: --add-host=hostname:127.0.0.1 --add-host=hostname:::1 --add-host=hostname=::1 --add-host=hostname=[::1] Signed-off-by: Rob Murray <[email protected]>
Fixes docker#4648 Make it easier to specify IPv6 addresses in the '--add-host' option by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: --add-host=hostname:127.0.0.1 --add-host=hostname:::1 --add-host=hostname=::1 --add-host=hostname:[::1] To avoid compatibility problems, the CLI will replace an '=' separator with ':', and strip brackets, before sending the request to the API. Signed-off-by: Rob Murray <[email protected]>
Fixes docker#4648 Make it easier to specify IPv6 addresses in the '--add-host' option by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: --add-host=hostname:127.0.0.1 --add-host=hostname:::1 --add-host=hostname=::1 --add-host=hostname:[::1] To avoid compatibility problems, the CLI will replace an '=' separator with ':', and strip brackets, before sending the request to the API. Signed-off-by: Rob Murray <[email protected]>
Fixes docker#4648 Make it easier to specify IPv6 addresses in the '--add-host' option by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: --add-host=my-hostname:127.0.0.1 --add-host=my-hostname:::1 --add-host=my-hostname=::1 --add-host=my-hostname:[::1] To avoid compatibility problems, the CLI will replace an '=' separator with ':', and strip brackets, before sending the request to the API. Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Make it easier to specify IPv6 addresses in the '--add-host' option by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: --add-host=hostname:127.0.0.1 --add-host=hostname:::1 --add-host=hostname=::1 --add-host=hostname=[::1] Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Update the 'extra_hosts' options to align with changes in 'docker/cli' and 'docker/buildx' that make it easier to specify IPv6 addresses in the '--add-host' option, by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: extra_hosts: - "somehost=162.242.195.82" - "myhostv6=::1" - "anotherhostv6=[2001:4860:4860::8888]" Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Update the 'extra_hosts' element to align with changes in 'docker/cli' and 'docker/buildx' that make it easier to specify IPv6 addresses in the '--add-host' option, by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: extra_hosts: - "somehost=162.242.195.82" - "myhostv6=::1" - "anotherhostv6=[2001:4860:4860::8888]" Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Update the 'extra_hosts' element to align with changes in 'docker/cli' and 'docker/buildx' that make it easier to specify IPv6 addresses in the '--add-host' option, by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: extra_hosts: - "somehost=162.242.195.82" - "myhostv6=::1" - "anotherhostv6=[2001:4860:4860::8888]" Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Align the format of 'extra_hosts' strings with '--add-hosts' options in the docker CLI and buildx - by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: extra_hosts: - "my-host1:127.0.0.1" - "my-host2:::1" - "my-host3=::1" - "my-host4=[::1]" Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Update the 'extra_hosts' element to align with changes in 'docker/cli' and 'docker/buildx' that make it easier to specify IPv6 addresses in the '--add-host' option, by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: extra_hosts: - "somehost=162.242.195.82" - "myhostv6=::1" - "anotherhostv6=[2001:4860:4860::8888]" Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Align the format of 'extra_hosts' strings with '--add-hosts' options in the docker CLI and buildx - by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: extra_hosts: - "my-host1:127.0.0.1" - "my-host2:::1" - "my-host3=::1" - "my-host4=[::1]" Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Align the format of 'extra_hosts' strings with '--add-hosts' options in the docker CLI and buildx - by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: extra_hosts: - "my-host1:127.0.0.1" - "my-host2:::1" - "my-host3=::1" - "my-host4=[::1]" Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Align the format of 'extra_hosts' strings with '--add-hosts' options in the docker CLI and buildx - by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: extra_hosts: - "my-host1:127.0.0.1" - "my-host2:::1" - "my-host3=::1" - "my-host4=[::1]" Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Update the 'extra_hosts' element to align with changes in 'docker/cli' and 'docker/buildx' that make it easier to specify IPv6 addresses in the '--add-host' option, by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: extra_hosts: - "somehost=162.242.195.82" - "myhostv6=::1" - "anotherhostv6=[2001:4860:4860::8888]" Signed-off-by: Rob Murray <[email protected]>
Fixes docker#4648 Make it easier to specify IPv6 addresses in the '--add-host' option by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: --add-host=my-hostname:127.0.0.1 --add-host=my-hostname:::1 --add-host=my-hostname=::1 --add-host=my-hostname:[::1] To avoid compatibility problems, the CLI will replace an '=' separator with ':', and strip brackets, before sending the request to the API. Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Align the format of 'extra_hosts' strings with '--add-hosts' options in the docker CLI and buildx - by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: extra_hosts: - "my-host1:127.0.0.1" - "my-host2:::1" - "my-host3=::1" - "my-host4=[::1]" Signed-off-by: Rob Murray <[email protected]>
Fixes docker/cli#4648 Make it easier to specify IPv6 addresses in the '--add-host' option by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: --add-host=hostname:127.0.0.1 --add-host=hostname:::1 --add-host=hostname=::1 --add-host=hostname=[::1] Signed-off-by: Rob Murray <[email protected]> (cherry picked from commit eeeff1c) Signed-off-by: Sebastiaan van Stijn <[email protected]>
Fixes docker#4648 Make it easier to specify IPv6 addresses in the '--add-host' option by permitting 'host=ip' in addition to 'host:ip', and allowing square brackets around the address. For example: --add-host=my-hostname:127.0.0.1 --add-host=my-hostname:::1 --add-host=my-hostname=::1 --add-host=my-hostname:[::1] To avoid compatibility problems, the CLI will replace an '=' separator with ':', and strip brackets, before sending the request to the API. Signed-off-by: Rob Murray <[email protected]>
Description
Using any ipv6 address with
--add-host
produces an error:Reproduce
Expected behavior
I am looking to be able to
curl -g -6 "http://[::1]:8080/"
from inside of the container. This is not possible, as--add-host
does not allow specifying[::1]
as the host's address.docker version
docker version Client: Cloud integration: v1.0.35+desktop.5 Version: 24.0.6 API version: 1.43 Go version: go1.20.7 Git commit: ed223bc Built: Mon Sep 4 12:28:49 2023 OS/Arch: darwin/arm64 Context: desktop-linux Server: Docker Desktop 4.25.0 (126437) Engine: Version: 24.0.6 API version: 1.43 (minimum version 1.12) Go version: go1.20.7 Git commit: 1a79695 Built: Mon Sep 4 12:31:36 2023 OS/Arch: linux/arm64 Experimental: true containerd: Version: 1.6.22 GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca runc: Version: 1.1.8 GitCommit: v1.1.8-0-g82f18fe docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info
Additional Info
daemon.json file:
The text was updated successfully, but these errors were encountered: