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

Allow port mapping only for endpoint created on docker run #17858

Merged
merged 2 commits into from Nov 11, 2015

Conversation

sanimej
Copy link

@sanimej sanimej commented Nov 10, 2015

Fixes #17824

port map config shouldn't be passed for the endpoint created using network connect.

Signed-off-by: Santhosh Manohar santhosh@docker.com

Santhosh Manohar and others added 2 commits November 6, 2015 13:54
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
created on network connect.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
@cpuguy83
Copy link
Member

-1 to boolean arguments, of which it seems there is already one.
Can we at least use a config struct?

createOptions, err := container.buildCreateEndpointOptions(n)
if err != nil {
return err
if createOption {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check whether this function can derive it is being called for the first network connect ?
Something like:

if len(container.NetworkSettings.Networks) == 1 { program the create option }

If so, caller does not need to pass any bool

// Other configs are applicable only for the endpoint in the network
// to which container was connected to on docker run.
if n.Name() != container.hostConfig.NetworkMode.NetworkName() &&
n.Name() != "bridge" {
Copy link
Contributor

Choose a reason for hiding this comment

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

this check essentially gives a free pass for the default bridge network even if the container is connected to the default bridge network using docker network connect.
But, the intention of the check should be to make sure we allow the rest of endpoint configs only for the network that is same as the NetworkMode.

Copy link
Contributor

Choose a reason for hiding this comment

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

The correct fix would be :

        container.hostConfig.NetworkMode.IsDefault() && n.Name() == controller.Config().Daemon.DefaultNetwork 

Copy link
Contributor

Choose a reason for hiding this comment

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

@mavenugo container.hostConfig.NetworkMode.IsDefault() && n.Name() == "bridge" should be ok, avoid passing the controller, see https://github.com/docker/docker/pull/17860/files#r44446197 from @aboch , bridge is hard code

Copy link
Contributor

Choose a reason for hiding this comment

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

@coolljt0725 @sanimej okay. Shall we wrap the above check in an utility function ?

@sanimej
Copy link
Author

sanimej commented Nov 11, 2015

@mavenugo PTAL. Since the check is done only in one place doing it inline is sufficient I think.

@coolljt0725
Copy link
Contributor

@sanimej Could use the test in #17860 to test the duplicate macaddress and fix the typo in https://github.com/docker/docker/pull/17860/files#diff-832e27741e70367e5566a720c88b8f32L937 so I can close my PR?

@sanimej
Copy link
Author

sanimej commented Nov 11, 2015

@coolljt0725 I picked up your commit and retained the test for the mac-address config.

@mavenugo
Copy link
Contributor

LGTM

@sanimej
Copy link
Author

sanimej commented Nov 11, 2015

@cpuguy83 PTAL

@calavera
Copy link
Contributor

LGTM

@erichin
Copy link

erichin commented Aug 2, 2016

LGTM

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

Successfully merging this pull request may close these issues.

None yet

9 participants