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

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

Signed-off-by: Danish Prakash <[email protected]>
@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.


The default host IP address to bind published container ports to when no host IP
is explicitly specified (e.g., `-p 8000:8000`). If empty, the default behavior is to
bind to all network interfaces (`0.0.0.0`). For instance, setting this to `127.0.0.1` restricts
Copy link
Member

Choose a reason for hiding this comment

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

but 0.0.0.0 isn't right? We bind to all address for v4 and v6, at least once we merge your PR and given this will go only into v6 we might document it right from the beginning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since containers/podman#27311 is still in progress, I didn't include it here. Would it be alright if we do that right away, and not wait until that PR is merged?

Copy link
Member

Choose a reason for hiding this comment

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

yes

// DefaultHostIP is the default host IP to bind published container ports
// to when no host IP is explicitly specified in the -p flag (e.g., -p 80:80).
// If empty, the default behavior is to bind to all interfaces (0.0.0.0).
DefaultHostIP string `toml:"default_host_ip,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I wonder should this be an array instead? Why limit to only one address? I could see someone wanting to use 127.0.0.1 and ::1 or maybe another local interface that is not exposed externally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds reasonable. But that would translate to two separate binds on the same port on different addresses iiuc.

Copy link
Member

Choose a reason for hiding this comment

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

right which seem reasonable. So basically a config like ["127.0.0.1","::1"] and port specified as -p 8080:80 will then get turned into two port mappings in podman so we treat it as 127.0.0.1:8080:80 and [::1]:8080:80

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