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

Podman CLI --add-host with multiple host for a single IP #23770

Closed
jerome59 opened this issue Aug 27, 2024 · 1 comment · Fixed by #23802
Closed

Podman CLI --add-host with multiple host for a single IP #23770

jerome59 opened this issue Aug 27, 2024 · 1 comment · Fixed by #23802
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@jerome59
Copy link
Contributor

Feature request description

Hello,

podman CLI has a parameter --add-host which allows us to add a mapping between a hostname and an IP (add line in the /etc/hosts file). This parameter can be set multiple times to add multiple mappings.
In case we have to set a lot of hostname which are mapped to the same IP, we could improve clarity by allowing to specify multiple hostname without duplicating the parameter --add-host.

This behavior is actually supported by default in the host files where we can map multiple hostnames to a single IP on a single line :
192.168.10.10 hostname1 hostname2

It is also supported by kube play (and kubernetes) :

  hostAliases:
  - hostnames:
    - hostname1
    - hostname2
    ip: 192.168.10.10
  

Suggest potential solution

From a user point of view, instead of writing the following when running a container or creating a pod :

--add-host=hostname1:192.168.10.10 --add-host=hostname2:192.168.10.10 --add-host=hostname3:192.168.10.10 --add-host=hostname4:192.168.10.11

I'd like to write :
--add-host=hostname1;hostname2;hostname3:192.168.10.10 --add-host=hostname4:192.168.10.11

Have you considered any alternatives?

A clear and concise description of any alternative solutions or features you've considered.

Additional context

This issue is opened following the comments on the following PR #23713 (review)

@jerome59 jerome59 added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 27, 2024
@Luap99
Copy link
Member

Luap99 commented Aug 27, 2024

Using a semicolon sounds fine with me, if this is implemented the new syntax would need to be add to ValidateExtraHost() in cmd/podman/parse/net.go and then in c/common/libnetwork where we generate the hosts file:
https://github.com/containers/common/blob/b001f1ae2b4ebd52b9bbd55ba6cb01d4422b62ef/libnetwork/etchosts/hosts.go#L235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants