MCPcopy
hub / github.com/opencontainers/runc / startContainer

Function startContainer

utils_linux.go:367–418  ·  view source on GitHub ↗
(context *cli.Context, action CtAct, criuOpts *libcontainer.CriuOpts)

Source from the content-addressed store, hash-verified

365)
366
367func startContainer(context *cli.Context, action CtAct, criuOpts *libcontainer.CriuOpts) (int, error) {
368 if err := revisePidFile(context); err != nil {
369 return -1, err
370 }
371 spec, err := setupSpec(context)
372 if err != nil {
373 return -1, err
374 }
375
376 id := context.Args().First()
377 if id == "" {
378 return -1, errEmptyID
379 }
380
381 notifySocket := newNotifySocket(context, os.Getenv("NOTIFY_SOCKET"), id)
382 if notifySocket != nil {
383 notifySocket.setupSpec(spec)
384 }
385
386 container, err := createContainer(context, id, spec)
387 if err != nil {
388 return -1, err
389 }
390
391 if notifySocket != nil {
392 if err := notifySocket.setupSocketDirectory(); err != nil {
393 return -1, err
394 }
395 if action == CT_ACT_RUN {
396 if err := notifySocket.bindSocket(); err != nil {
397 return -1, err
398 }
399 }
400 }
401
402 r := &runner{
403 enableSubreaper: !context.Bool("no-subreaper"),
404 shouldDestroy: !context.Bool("keep"),
405 container: container,
406 listenFDs: activation.Files(), // On-demand socket activation.
407 notifySocket: notifySocket,
408 consoleSocket: context.String("console-socket"),
409 pidfdSocket: context.String("pidfd-socket"),
410 detach: context.Bool("detach"),
411 pidFile: context.String("pid-file"),
412 preserveFDs: context.Int("preserve-fds"),
413 action: action,
414 criuOpts: criuOpts,
415 init: true,
416 }
417 return r.run(spec.Process)
418}
419
420func setupPidfdSocket(process *libcontainer.Process, sockpath string) (_clean func(), _ error) {
421 linux530 := kernelversion.KernelVersion{Kernel: 5, Major: 3}

Callers 3

restore.goFile · 0.85
run.goFile · 0.85
create.goFile · 0.85

Calls 10

runMethod · 0.95
FilesFunction · 0.92
revisePidFileFunction · 0.85
setupSpecFunction · 0.85
newNotifySocketFunction · 0.85
createContainerFunction · 0.85
setupSpecMethod · 0.80
setupSocketDirectoryMethod · 0.80
bindSocketMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…