File: start_linux.go

package info (click to toggle)
docker.io 27.5.1%2Bdfsg4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,384 kB
  • sloc: sh: 5,847; makefile: 1,146; ansic: 664; python: 162; asm: 133
file content (31 lines) | stat: -rw-r--r-- 1,056 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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"
	specs "github.com/opencontainers/runtime-spec/specs-go"
	"go.opentelemetry.io/otel"
)

// 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 {
	ctx, span := otel.Tracer("").Start(ctx, "daemon.initializeCreatedTask")
	defer span.End()

	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)
			}
			return sb.FinishConfig(ctx)
		}
	}
	return nil
}