Skip to content

Conversation

@danishprakash
Copy link
Contributor

This adds support for configuring a default host IP via containers.conf to bind published container ports to when no host IP is explicitly specified (e.g. -p 8000:8000). Note that explicit host IP still overrides the default option set in containers.conf.

Refers containers/podman#27186

@github-actions github-actions bot added the common Related to "common" package label Oct 28, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 28, 2025
@podmanbot
Copy link

✅ A new PR has been created in buildah to vendor these changes: containers/buildah#6458

@TomSweeneyRedHat
Copy link
Member

LGTM
@Luap99 ?

@lng-sys
Copy link

lng-sys commented Nov 2, 2025

Just out of curiosity: was DefaultHostIP already a thing and it just needed to be exposed as default_host_ip in containers.conf?

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

This also needs a basic unit test to confirm the option is getting parsed properly.

podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 13, 2025
@danishprakash danishprakash changed the title common: add support for default_host_ip in containers.conf common: add support for default_host_ips in containers.conf Nov 13, 2025
This adds support for configuring default host IPs via containers.conf
to bind published container ports to when no host IP is explicitly
specified (e.g. -p 8000:8000). If multiple IPs are specified,
separate port mapping for each of the specified IP would be created.
For instance, setting this to `["127.0.0.1", "::1"]` and port specified
as `-p 8080:80` will result into two port mappings in podman--
`127.0.0.1:8080:80` and `[::1]:8080:80`.

Note that explicit host IP still overrides the default option set in containers.conf.

Refers containers/podman#27186

Signed-off-by: Danish Prakash <[email protected]>
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 13, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 13, 2025
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Please also add a basic test to ensure the field is parsed properly.

// If empty, the default behavior is to bind to all interfaces (0.0.0.0).
// If multiple IPs are specified, separate port mapping for each of the specified
// IP would be created.
DefaultHostIPs []string `toml:"default_host_ips,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

this should use attributedstring.Slice like other array to support appending accordingly

Also not trying to bikeshed but I wonder if default_host_ips is the best name here? Should it be default_publish_ips or default_port_bind_ips? HostIP IMO could be assumed to be something else unrelated to port mappings, i.e. we already have host_containers_internal_ip for example.

behavior is to bind to all network interfaces (`0.0.0.0`). If multiple IPs are specified,
separate port mapping for each of the specified IP would be created. For instance, setting
this to `["127.0.0.1", "::1"]` and port specified as `-p 8080:80` will result into two
port mappings in podman--`127.0.0.1:8080:80` and `[::1]:8080:80`.
Copy link
Member

Choose a reason for hiding this comment

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

typo here with --

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants