Skip to content

Commit

Permalink
Merge pull request moby#39589 from thaJeztah/prevent_network_attach_p…
Browse files Browse the repository at this point in the history
…anic

Prevent panic on network attach
  • Loading branch information
yongtang committed Jul 29, 2019
2 parents 917a8b4 + 651e694 commit 9c92080
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion daemon/container_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ func (daemon *Daemon) buildSandboxOptions(container *container.Container) ([]lib

func (daemon *Daemon) updateNetworkSettings(container *container.Container, n libnetwork.Network, endpointConfig *networktypes.EndpointSettings) error {
if container.NetworkSettings == nil {
container.NetworkSettings = &network.Settings{Networks: make(map[string]*network.EndpointSettings)}
container.NetworkSettings = &network.Settings{}
}
if container.NetworkSettings.Networks == nil {
container.NetworkSettings.Networks = make(map[string]*network.EndpointSettings)
}

if !container.HostConfig.NetworkMode.IsHost() && containertypes.NetworkMode(n.Type()).IsHost() {
Expand Down

0 comments on commit 9c92080

Please sign in to comment.