2022-11-01 19:21:37 +00:00
|
|
|
package daemon // import "github.com/docker/docker/daemon"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/docker/docker/container"
|
|
|
|
"github.com/docker/docker/errdefs"
|
|
|
|
"github.com/docker/docker/libcontainerd/types"
|
|
|
|
"github.com/docker/docker/oci"
|
2024-03-23 16:49:53 +00:00
|
|
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
2022-11-01 19:21:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// initializeCreatedTask performs any initialization that needs to be done to
|
|
|
|
// prepare a freshly-created task to be started.
|
|
|
|
func (daemon *Daemon) initializeCreatedTask(ctx context.Context, tsk types.Task, container *container.Container, spec *specs.Spec) error {
|
|
|
|
if !container.Config.NetworkDisabled {
|
|
|
|
nspath, ok := oci.NamespacePath(spec, specs.NetworkNamespace)
|
|
|
|
if ok && nspath == "" { // the runtime has been instructed to create a new network namespace for tsk.
|
|
|
|
sb, err := daemon.netController.GetSandbox(container.ID)
|
|
|
|
if err != nil {
|
|
|
|
return errdefs.System(err)
|
|
|
|
}
|
2024-03-23 16:49:53 +00:00
|
|
|
return sb.FinishConfig()
|
2022-11-01 19:21:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|