-
Notifications
You must be signed in to change notification settings - Fork 38
common: add support for default_host_ip in containers.conf
#422
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
base: main
Are you sure you want to change the base?
Conversation
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]>
|
✅ A new PR has been created in buildah to vendor these changes: containers/buildah#6458 |
|
LGTM |
|
Just out of curiosity: was DefaultHostIP already a thing and it just needed to be exposed as default_host_ip in containers.conf? |
Luap99
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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