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

Forcing a nil IP specified in PortBindings to IPv4zero (0.0.0.0). #2376

Merged
merged 1 commit into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions drivers/windows/port_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ func allocatePort(portMapper *portmapper.PortMapper, bnd *types.PortBinding, con
err error
)

// Windows does not support a host ip for port bindings (this is validated in ConvertPortBindings()).
// If the HostIP is nil, force it to be 0.0.0.0 for use as the key in portMapper.
if bnd.HostIP == nil {
bnd.HostIP = net.IPv4zero
}

// Store the container interface address in the operational binding
bnd.IP = containerIP

Expand Down
2 changes: 1 addition & 1 deletion drivers/windows/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ func ConvertPortBindings(portBindings []types.PortBinding) ([]json.RawMessage, e
return nil, fmt.Errorf("Windows does not support more than one host port in NAT settings")
}

if len(elem.HostIP) != 0 {
if len(elem.HostIP) != 0 && !elem.HostIP.IsUnspecified() {
return nil, fmt.Errorf("Windows does not support host IP addresses in NAT settings")
}

Expand Down