Skip to content

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

@jerome59

Description

@jerome59

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.locked - please file new issue/PRAssist humans wanting to comment on an old issue or PR with locked comments.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions