Skip to content
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

Permit '=' separator and '[ipv6]' in 'extra_hosts'. #499

Merged
merged 1 commit into from
Nov 23, 2023

Conversation

robmry
Copy link
Contributor

@robmry robmry commented Nov 22, 2023

Fixes docker/cli#4648

Align the format of extra_hosts strings with updated --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]"

Added HostsList unit tests for the various input formats.

@robmry robmry requested a review from ndeloof as a code owner November 22, 2023 11:55
Copy link
Collaborator

@ndeloof ndeloof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
a minor note on extending decodeMapping to support both scenarios

types/hostList.go Outdated Show resolved Hide resolved
@robmry robmry force-pushed the extra_hosts_eq_sep_and_brackets branch 2 times, most recently from ddcc3a1 to 984ecda Compare November 23, 2023 10:12
@ndeloof
Copy link
Collaborator

ndeloof commented Nov 23, 2023

to promote use of = , HostsList.AsList() should also use it when rendering canonical compose.yaml with docker compose config

@robmry
Copy link
Contributor Author

robmry commented Nov 23, 2023

to promote use of = , HostsList.AsList() should also use it when rendering canonical compose.yaml with docker compose config

I'm still figuring out how all this stuff fits together - but the engine API won't understand =, it's up to the CLI/buildx/compose clients to convert back to : (less human-readable, but a stable API that avoids problems with an old engine vs. new client).

So, I think, if the docker compose config is what ends up being sent to the API (?), it'll need to stick with the :?

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ipv6 addresses with square brackets cannot be used with the --add-host option
2 participants