Skip to content

Commit afdfe4f

Browse files
committed
runconfig: deprecate SetDefaultNetModeIfBlank
Remove uses of this function and mark it deprecated. There's no known consumers of this function, but let's stay on the safe side, and mark it deprected for 1 release. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 4af9f41 commit afdfe4f

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

daemon/container.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/containerd/log"
1212
containertypes "github.com/docker/docker/api/types/container"
13+
networktypes "github.com/docker/docker/api/types/network"
1314
"github.com/docker/docker/api/types/strslice"
1415
"github.com/docker/docker/container"
1516
"github.com/docker/docker/daemon/config"
@@ -19,7 +20,6 @@ import (
1920
"github.com/docker/docker/oci/caps"
2021
"github.com/docker/docker/opts"
2122
"github.com/docker/docker/pkg/system"
22-
"github.com/docker/docker/runconfig"
2323
volumemounts "github.com/docker/docker/volume/mounts"
2424
"github.com/docker/go-connections/nat"
2525
"github.com/moby/sys/signal"
@@ -218,7 +218,9 @@ func (daemon *Daemon) setHostConfig(container *container.Container, hostConfig *
218218
return err
219219
}
220220

221-
runconfig.SetDefaultNetModeIfBlank(hostConfig)
221+
if hostConfig != nil && hostConfig.NetworkMode == "" {
222+
hostConfig.NetworkMode = networktypes.NetworkDefault
223+
}
222224
container.HostConfig = hostConfig
223225
return nil
224226
}

daemon/create.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ func (daemon *Daemon) create(ctx context.Context, daemonCfg *config.Config, opts
231231
}
232232
// Make sure NetworkMode has an acceptable value. We do this to ensure
233233
// backwards API compatibility.
234-
runconfig.SetDefaultNetModeIfBlank(ctr.HostConfig)
234+
if ctr.HostConfig != nil && ctr.HostConfig.NetworkMode == "" {
235+
ctr.HostConfig.NetworkMode = networktypes.NetworkDefault
236+
}
235237

236238
daemon.updateContainerNetworkSettings(ctr, endpointsConfigs)
237239
if err := daemon.Register(ctr); err != nil {

runconfig/hostconfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
// to default if it is not populated. This ensures backwards compatibility after
1212
// the validation of the network mode was moved from the docker CLI to the
1313
// docker daemon.
14+
//
15+
// Deprecated: SetDefaultNetModeIfBlank is no longer used abnd will be removed in the next release.
1416
func SetDefaultNetModeIfBlank(hc *container.HostConfig) {
1517
if hc != nil && hc.NetworkMode == "" {
1618
hc.NetworkMode = network.NetworkDefault

0 commit comments

Comments
 (0)