Skip to content

Commit

Permalink
update PortBinding logic
Browse files Browse the repository at this point in the history
  • Loading branch information
xmh19936688 committed May 18, 2023
1 parent 59eca37 commit 959635c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,13 @@ func (p *DockerProvider) preCreateContainerHook(ctx context.Context, req Contain
}

dockerInput.ExposedPorts = exposedPortSet
hostConfig.PortBindings = mergePortBindings(hostConfig.PortBindings, exposedPortMap, req.ExposedPorts)

// only exposing those ports automatically if the container request exposes zero ports and the container does not run in a container network
if len(exposedPorts) == 0 && !hostConfig.NetworkMode.IsContainer() {
hostConfig.PortBindings = exposedPortMap
} else {
hostConfig.PortBindings = mergePortBindings(hostConfig.PortBindings, exposedPortMap, req.ExposedPorts)
}

return nil
}
Expand Down

0 comments on commit 959635c

Please sign in to comment.