Support network connect/disconnect to stopped container#18906
Support network connect/disconnect to stopped container#18906thaJeztah merged 1 commit intomoby:masterfrom
Conversation
71e7a76 to
c4c4997
Compare
|
Awesome, thanks @coolljt0725! |
There was a problem hiding this comment.
Slight typo: netwokr -> network
c4c4997 to
366fa37
Compare
|
@sirlatrom thank you :) |
daemon/container_operations_unix.go
Outdated
There was a problem hiding this comment.
Instead of branching with a whole bunch of logic, can we move this to a new function?
I also haven't looked yet, but I'm guessing there is probably some duplicated logic here?
There was a problem hiding this comment.
Yes. we can avoid the code duplication by simply moving the if !container.Running { check to https://github.com/docker/docker/blob/master/daemon/container_operations_unix.go#L645.
This will avoid the code duplication. But the tricky part will be differentiate the common code-path for connectToNetwork both from docker run command and docker network connect. We may have to check for a better container state than container.Running because it might be false when called via docker run & hence might cause issues.
There was a problem hiding this comment.
or (though I don't like this approach) add another bool flag to connectToNetwork.
There was a problem hiding this comment.
The real issue here is that when the container is not running we are doing something completely different and then returning 100% of the time, there is no shared logic with the code beneath, so for readability it'd be best to move this out to a separate function.
There was a problem hiding this comment.
yes. that is also a way to avoid the code-duplication issue & I like it as well.
|
ping @mrjana |
d74dd44 to
430b24c
Compare
|
@coolljt0725 not in docs review yet, but there are some minor changes needed in the documentation;
|
daemon/container_operations_unix.go
Outdated
There was a problem hiding this comment.
minor nit. The appropriate function name would be updateNetworkConfig since it does update both the container.Config and also the network specific settings. Can you please change that ?
|
@coolljt0725 minor comments. Rest of the code and logic LGTM. |
daemon/container_operations_unix.go
Outdated
There was a problem hiding this comment.
I would use the same "new errcode" referenced in the comment above.
430b24c to
80dcd11
Compare
|
early docs review; docs LGTM |
|
LGTM, nice work! Moving to docs review. |
|
Ping @jamtur01 @MHBauer @vdemeester 🌴 |
errors/daemon.go
Outdated
There was a problem hiding this comment.
I'd probably do:
... connected or disconnected to the network
And same with error msg below too
|
Docs LGTM - one minor comment. |
|
@coolljt0725 agree with @jamtur01 comment, once taking care of, LGTM 🐰 |
06b78d0 to
79d4f0f
Compare
Signed-off-by: Lei Jitang <[email protected]>
|
@jamtur01 @vdemeester thanks, updated |
|
docs LGTM Hum, I don't get why the documentation build has failures… I do not reproduce the failures locally 😓. |
|
@vdemeester It's weird, I just taken care of the comment of @jamtur01 , no other changes |
hmf, yes, that error is not related, it's an issue with Hugo (probably); see gohugoio/hugo#1754 @SvenDowideit was looking into those, but not sure if he has progress. |
|
Hmm, looks like GitHub is having issues with their SVN integration on docker/compose? Manually doing a svn checkout also produces an error (just on the compose repository); |
|
Sent an e-mail to GitHub support for the SVN issue |
|
LGTM - docs failure is not related |
Support network connect/disconnect to stopped container
|
ping @albers We may need to update bash and zsh completion |
|
@sdurrheimer Thanks for the ping, created #19293 for bash completion. |
Signed-off-by: Lei Jitang [email protected]
see #17796
ping @mavenugo