@@ -396,61 +396,256 @@ Defaults to 20G.
396396C:\> dockerd --storage-opt size=40G
397397```
398398
399- ### Docker runtime execution options
399+ ### Runtime options
400400
401401The Docker daemon relies on a
402402[ OCI] ( https://github.com/opencontainers/runtime-spec ) compliant runtime
403403(invoked via the ` containerd ` daemon) as its interface to the Linux
404404kernel ` namespaces ` , ` cgroups ` , and ` SELinux ` .
405405
406- By default, the Docker daemon automatically starts ` containerd ` . If you want to
407- control ` containerd ` startup, manually start ` containerd ` and pass the path to
408- the ` containerd ` socket using the ` --containerd ` flag. For example:
406+ #### Configure container runtimes
407+
408+ By default, the Docker daemon uses runc as a container runtime.
409+ You can configure the daemon to add additional runtimes.
410+
411+ containerd shims installed on ` PATH ` can be used directly, without the need
412+ to edit the daemon's configuration. For example, if you install the Kata
413+ Containers shim (` containerd-shim-kata-v2 ` ) on ` PATH ` , then you can select that
414+ runtime with ` docker run ` without having to edit the daemon's configuration:
409415
410416``` console
411- $ sudo dockerd --containerd /var/run/dev/docker- containerd.sock
417+ $ docker run --runtime io. containerd.kata.v2
412418```
413419
414- Runtimes can be registered with the daemon either via the
415- configuration file or using the ` --add-runtime ` command line argument.
420+ Container runtimes that don't implement containerd shims, or containerd shims
421+ installed outside of ` PATH ` , must be registered with the daemon, either via the
422+ configuration file or using the ` --add-runtime ` command line flag.
423+
424+ For examples on how to use other container runtimes, see
425+ [ Alternative container runtimes] ( https://docs.docker.com/engine/alternative-container-runtimes )
426+
427+ ##### Configure runtimes using ` daemon.json `
416428
417- The following is an example adding 2 runtimes via the configuration:
429+ To register and configure container runtimes using the daemon's configuration
430+ file, add the runtimes as entries under ` runtimes ` :
418431
419432``` json
420433{
421- "default-runtime" : " runc" ,
422434 "runtimes" : {
423- "custom" : {
424- "path" : " /usr/local/bin/my-runc-replacement" ,
425- "runtimeArgs" : [
426- " --debug"
427- ]
435+ "<runtime>" : {}
436+ }
437+ }
438+ ```
439+
440+ The key of the entry (` <runtime> ` in the previous example) represents the name
441+ of the runtime. This is the name that you reference when you run a container,
442+ using ` docker run --runtime <runtime> ` .
443+
444+ The runtime entry contains an object specifying the configuration for your
445+ runtime. The properties of the object depends on what kind of runtime you're
446+ looking to register:
447+
448+ - If the runtime implements its own containerd shim, the object shall contain
449+ a ` runtimeType ` field and an optional ` options ` field.
450+
451+ ``` json
452+ {
453+ "runtimes" : {
454+ "<runtime>" : {
455+ "runtimeType" : " <name-or-path>" ,
456+ "options" : {}
457+ }
458+ }
459+ }
460+ ```
461+
462+ See [ Configure shims] ( #configure-containerd-shims ) .
463+
464+ - If the runtime is designed to be a drop-in replacement for runc,
465+ the object contains a ` path ` field, and an optional ` runtimeArgs ` field.
466+
467+ ``` json
468+ {
469+ "runtimes" : {
470+ "<runtime>" : {
471+ "path" : " /path/to/bin" ,
472+ "runtimeArgs" : [" ...args" ]
473+ }
474+ }
475+ }
476+ ```
477+
478+ See [ Configure runc drop-in replacements] ( #configure-runc-drop-in-replacements ) .
479+
480+ After changing the runtimes configuration in the configuration file,
481+ you must reload or restart the daemon for changes to take effect:
482+
483+ ``` console
484+ $ sudo systemctl reload dockerd
485+ ```
486+
487+ ##### Configure containerd shims
488+
489+ If the runtime that you want to register implements a containerd shim,
490+ or if you want to register a runtime which uses the runc shim,
491+ use the following format for the runtime entry:
492+
493+ ``` json
494+ {
495+ "runtimes" : {
496+ "<runtime>" : {
497+ "runtimeType" : " <name-or-path>" ,
498+ "options" : {}
499+ }
500+ }
501+ }
502+ ```
503+
504+ ` runtimeType ` refers to either:
505+
506+ - A fully qualified name of a containerd shim.
507+
508+ The fully qualified name of a shim is the same as the ` runtime_type ` used to
509+ register the runtime in containerd's CRI configuration.
510+ For example, ` io.containerd.runsc.v1 ` .
511+
512+ - The path of a containerd shim binary.
513+
514+ This option is useful if you installed the containerd shim binary outside of
515+ ` PATH ` .
516+
517+ ` options ` is optional. It lets you specify the runtime configuration that you
518+ want to use for the shim. The configuration parameters that you can specify in
519+ ` options ` depends on the runtime you're registering. For most shims,
520+ the supported configuration options are ` TypeUrl ` and ` ConfigPath ` .
521+ For example:
522+
523+ ``` json
524+ {
525+ "runtimes" : {
526+ "gvisor" : {
527+ "runtimeType" : " io.containerd.runsc.v1" ,
528+ "options" : {
529+ "TypeUrl" : " io.containerd.runsc.v1.options" ,
530+ "ConfigPath" : " /etc/containerd/runsc.toml" ,
531+ }
532+ }
533+ }
534+ }
535+ ```
536+
537+ You can configure multiple runtimes using the same runtimeType. For example:
538+
539+ ``` json
540+ {
541+ "runtimes" : {
542+ "gvisor-foo" : {
543+ "runtimeType" : " io.containerd.runsc.v1" ,
544+ "options" : {
545+ "TypeUrl" : " io.containerd.runsc.v1.options" ,
546+ "ConfigPath" : " /etc/containerd/runsc-foo.toml"
547+ }
428548 },
549+ "gvisor-bar" : {
550+ "runtimeType" : " io.containerd.runsc.v1" ,
551+ "options" : {
552+ "TypeUrl" : " io.containerd.runsc.v1.options" ,
553+ "ConfigPath" : " /etc/containerd/runsc-bar.toml"
554+ }
555+ }
556+ }
557+ }
558+ ```
559+
560+ The ` options ` field takes a special set of configuration parameters when used
561+ with ` "runtimeType": "io.containerd.runc.v2" ` . For more information about runc
562+ parameters, refer to the runc configuration section in
563+ [ CRI Plugin Config Guide] ( https://github.com/containerd/containerd/blob/v1.7.2/docs/cri/config.md#full-configuration ) .
564+
565+ ##### Configure runc drop-in replacements
566+
567+ If the runtime that you want to register can act as a drop-in replacement for
568+ runc, you can register the runtime either using the daemon configuration file,
569+ or using the ` --add-runtime ` flag for the ` dockerd ` cli.
570+
571+ When you use the configuration file, the entry uses the following format:
572+
573+ ``` json
574+ {
575+ "runtimes" : {
576+ "<runtime>" : {
577+ "path" : " /path/to/binary" ,
578+ "runtimeArgs" : [" ...args" ]
579+ }
580+ }
581+ }
582+ ```
583+
584+ Where ` path ` is either the absolute path to the runtime executable, or the name
585+ of an executable installed on ` PATH ` :
586+
587+ ``` json
588+ {
589+ "runtimes" : {
429590 "runc" : {
430591 "path" : " runc"
431592 }
432593 }
433594}
434595```
435596
436- This is the same example via the command line:
597+ And ` runtimeArgs ` lets you optionally pass additional arguments to the runtime.
598+ Entries with this format use the containerd runc shim to invoke a custom
599+ runtime binary.
600+
601+ When you use the ` --add-runtime ` CLI flag, use the following format:
437602
438603``` console
439- $ sudo dockerd --add-runtime runc=runc --add- runtime custom=/usr/local/bin/my-runc-replacement
604+ $ sudo dockerd --add-runtime < runtime> = < path >
440605```
441606
442- > ** Note**
443- >
444- > Defining runtime arguments via the command line is not supported.
607+ Defining runtime arguments via the command line is not supported.
608+
609+ For an example configuration for a runc drop-in replacment, see
610+ [ Alternative container runtimes > youki] ( https://docs.docker.com/engine/alternative-runtimes/#youki )
611+
612+ ##### Configure the default container runtime
613+
614+ You can specify either the name of a fully qualified containerd runtime shim,
615+ or the name of a registered runtime. You can specify the default runtime either
616+ using the daemon configuration file, or using the ` --default-runtime ` flag for
617+ the ` dockerd ` cli.
445618
446- #### Options for the runtime
619+ When you use the configuration file, the entry uses the following format:
447620
448- You can configure the runtime using options specified
449- with the ` --exec-opt ` flag. All the flag's options have the ` native ` prefix. A
450- single ` native.cgroupdriver ` option is available.
621+ ``` json
622+ {
623+ "default-runtime" : " io.containerd.runsc.v1"
624+ }
625+ ```
451626
452- The ` native.cgroupdriver ` option specifies the management of the container's
453- cgroups. You can only specify ` cgroupfs ` or ` systemd ` . If you specify
627+ When you use the ` --default-runtime ` CLI flag, use the following format:
628+
629+ ``` console
630+ $ dockerd --default-runtime io.containerd.runsc.v1
631+ ```
632+
633+ #### Run containerd standalone
634+
635+ By default, the Docker daemon automatically starts ` containerd ` . If you want to
636+ control ` containerd ` startup, manually start ` containerd ` and pass the path to
637+ the ` containerd ` socket using the ` --containerd ` flag. For example:
638+
639+ ``` console
640+ $ sudo dockerd --containerd /run/containerd/containerd.sock
641+ ```
642+
643+ #### Configure cgroup driver
644+
645+ You can configure how the runtime should manage container cgroups, using the
646+ ` --exec-opt native.cgroupdriver ` CLI flag.
647+
648+ You can only specify ` cgroupfs ` or ` systemd ` . If you specify
454649` systemd ` and it is not available, the system errors out. If you omit the
455650` native.cgroupdriver ` option,` cgroupfs ` is used on cgroup v1 hosts, ` systemd `
456651is used on cgroup v2 hosts with systemd available.
@@ -463,16 +658,19 @@ $ sudo dockerd --exec-opt native.cgroupdriver=systemd
463658
464659Setting this option applies to all containers the daemon launches.
465660
466- Also Windows Container makes use of ` --exec-opt ` for special purpose. Docker user
467- can specify default container isolation technology with this, for example:
661+ #### Configure container isolation technology (Windows)
662+
663+ For Windows containers, you can specify the default container isolation
664+ technology to use, using the ` --exec-opt isolation ` flag.
665+
666+ The following example makes ` hyperv ` the default isolation technology:
468667
469668``` console
470669> dockerd --exec-opt isolation=hyperv
471670```
472671
473- Will make ` hyperv ` the default isolation technology on Windows. If no isolation
474- value is specified on daemon start, on Windows client, the default is
475- ` hyperv ` , and on Windows server, the default is ` process ` .
672+ If no isolation value is specified on daemon start, on Windows client,
673+ the default is ` hyperv ` , and on Windows server, the default is ` process ` .
476674
477675### Daemon DNS options
478676
0 commit comments