Skip to content

Commit ee62dcd

Browse files
authored
Merge pull request #4369 from thaJeztah/24.0_backport_dockerd-runtimes-refresh
[24.0 backport] docs: update the runtime configuration section
2 parents b3750a8 + c3ef1ce commit ee62dcd

1 file changed

Lines changed: 228 additions & 30 deletions

File tree

docs/reference/commandline/dockerd.md

Lines changed: 228 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -828,61 +828,256 @@ Defaults to 20G.
828828
C:\> dockerd --storage-opt size=40G
829829
```
830830

831-
### Docker runtime execution options
831+
### Runtime options
832832

833833
The Docker daemon relies on a
834834
[OCI](https://github.com/opencontainers/runtime-spec) compliant runtime
835835
(invoked via the `containerd` daemon) as its interface to the Linux
836836
kernel `namespaces`, `cgroups`, and `SELinux`.
837837

838-
By default, the Docker daemon automatically starts `containerd`. If you want to
839-
control `containerd` startup, manually start `containerd` and pass the path to
840-
the `containerd` socket using the `--containerd` flag. For example:
838+
#### Configure container runtimes
839+
840+
By default, the Docker daemon uses runc as a container runtime.
841+
You can configure the daemon to add additional runtimes.
842+
843+
containerd shims installed on `PATH` can be used directly, without the need
844+
to edit the daemon's configuration. For example, if you install the Kata
845+
Containers shim (`containerd-shim-kata-v2`) on `PATH`, then you can select that
846+
runtime with `docker run` without having to edit the daemon's configuration:
841847

842848
```console
843-
$ sudo dockerd --containerd /var/run/dev/docker-containerd.sock
849+
$ docker run --runtime io.containerd.kata.v2
844850
```
845851

846-
Runtimes can be registered with the daemon either via the
847-
configuration file or using the `--add-runtime` command line argument.
852+
Container runtimes that don't implement containerd shims, or containerd shims
853+
installed outside of `PATH`, must be registered with the daemon, either via the
854+
configuration file or using the `--add-runtime` command line flag.
855+
856+
For examples on how to use other container runtimes, see
857+
[Alternative container runtimes](https://docs.docker.com/engine/alternative-container-runtimes)
858+
859+
##### Configure runtimes using `daemon.json`
848860

849-
The following is an example adding 2 runtimes via the configuration:
861+
To register and configure container runtimes using the daemon's configuration
862+
file, add the runtimes as entries under `runtimes`:
850863

851864
```json
852865
{
853-
"default-runtime": "runc",
854866
"runtimes": {
855-
"custom": {
856-
"path": "/usr/local/bin/my-runc-replacement",
857-
"runtimeArgs": [
858-
"--debug"
859-
]
867+
"<runtime>": {}
868+
}
869+
}
870+
```
871+
872+
The key of the entry (`<runtime>` in the previous example) represents the name
873+
of the runtime. This is the name that you reference when you run a container,
874+
using `docker run --runtime <runtime>`.
875+
876+
The runtime entry contains an object specifying the configuration for your
877+
runtime. The properties of the object depends on what kind of runtime you're
878+
looking to register:
879+
880+
- If the runtime implements its own containerd shim, the object shall contain
881+
a `runtimeType` field and an optional `options` field.
882+
883+
```json
884+
{
885+
"runtimes": {
886+
"<runtime>": {
887+
"runtimeType": "<name-or-path>",
888+
"options": {}
889+
}
890+
}
891+
}
892+
```
893+
894+
See [Configure shims](#configure-containerd-shims).
895+
896+
- If the runtime is designed to be a drop-in replacement for runc,
897+
the object contains a `path` field, and an optional `runtimeArgs` field.
898+
899+
```json
900+
{
901+
"runtimes": {
902+
"<runtime>": {
903+
"path": "/path/to/bin",
904+
"runtimeArgs": ["...args"]
905+
}
906+
}
907+
}
908+
```
909+
910+
See [Configure runc drop-in replacements](#configure-runc-drop-in-replacements).
911+
912+
After changing the runtimes configuration in the configuration file,
913+
you must reload or restart the daemon for changes to take effect:
914+
915+
```console
916+
$ sudo systemctl reload dockerd
917+
```
918+
919+
##### Configure containerd shims
920+
921+
If the runtime that you want to register implements a containerd shim,
922+
or if you want to register a runtime which uses the runc shim,
923+
use the following format for the runtime entry:
924+
925+
```json
926+
{
927+
"runtimes": {
928+
"<runtime>": {
929+
"runtimeType": "<name-or-path>",
930+
"options": {}
931+
}
932+
}
933+
}
934+
```
935+
936+
`runtimeType` refers to either:
937+
938+
- A fully qualified name of a containerd shim.
939+
940+
The fully qualified name of a shim is the same as the `runtime_type` used to
941+
register the runtime in containerd's CRI configuration.
942+
For example, `io.containerd.runsc.v1`.
943+
944+
- The path of a containerd shim binary.
945+
946+
This option is useful if you installed the containerd shim binary outside of
947+
`PATH`.
948+
949+
`options` is optional. It lets you specify the runtime configuration that you
950+
want to use for the shim. The configuration parameters that you can specify in
951+
`options` depends on the runtime you're registering. For most shims,
952+
the supported configuration options are `TypeUrl` and `ConfigPath`.
953+
For example:
954+
955+
```json
956+
{
957+
"runtimes": {
958+
"gvisor": {
959+
"runtimeType": "io.containerd.runsc.v1",
960+
"options": {
961+
"TypeUrl": "io.containerd.runsc.v1.options",
962+
"ConfigPath": "/etc/containerd/runsc.toml",
963+
}
964+
}
965+
}
966+
}
967+
```
968+
969+
You can configure multiple runtimes using the same runtimeType. For example:
970+
971+
```json
972+
{
973+
"runtimes": {
974+
"gvisor-foo": {
975+
"runtimeType": "io.containerd.runsc.v1",
976+
"options": {
977+
"TypeUrl": "io.containerd.runsc.v1.options",
978+
"ConfigPath": "/etc/containerd/runsc-foo.toml"
979+
}
860980
},
981+
"gvisor-bar": {
982+
"runtimeType": "io.containerd.runsc.v1",
983+
"options": {
984+
"TypeUrl": "io.containerd.runsc.v1.options",
985+
"ConfigPath": "/etc/containerd/runsc-bar.toml"
986+
}
987+
}
988+
}
989+
}
990+
```
991+
992+
The `options` field takes a special set of configuration parameters when used
993+
with `"runtimeType": "io.containerd.runc.v2"`. For more information about runc
994+
parameters, refer to the runc configuration section in
995+
[CRI Plugin Config Guide](https://github.com/containerd/containerd/blob/v1.7.2/docs/cri/config.md#full-configuration).
996+
997+
##### Configure runc drop-in replacements
998+
999+
If the runtime that you want to register can act as a drop-in replacement for
1000+
runc, you can register the runtime either using the daemon configuration file,
1001+
or using the `--add-runtime` flag for the `dockerd` cli.
1002+
1003+
When you use the configuration file, the entry uses the following format:
1004+
1005+
```json
1006+
{
1007+
"runtimes": {
1008+
"<runtime>": {
1009+
"path": "/path/to/binary",
1010+
"runtimeArgs": ["...args"]
1011+
}
1012+
}
1013+
}
1014+
```
1015+
1016+
Where `path` is either the absolute path to the runtime executable, or the name
1017+
of an executable installed on `PATH`:
1018+
1019+
```json
1020+
{
1021+
"runtimes": {
8611022
"runc": {
8621023
"path": "runc"
8631024
}
8641025
}
8651026
}
8661027
```
8671028

868-
This is the same example via the command line:
1029+
And `runtimeArgs` lets you optionally pass additional arguments to the runtime.
1030+
Entries with this format use the containerd runc shim to invoke a custom
1031+
runtime binary.
1032+
1033+
When you use the `--add-runtime` CLI flag, use the following format:
8691034

8701035
```console
871-
$ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-runc-replacement
1036+
$ sudo dockerd --add-runtime <runtime>=<path>
8721037
```
8731038

874-
> **Note**
875-
>
876-
> Defining runtime arguments via the command line is not supported.
1039+
Defining runtime arguments via the command line is not supported.
1040+
1041+
For an example configuration for a runc drop-in replacment, see
1042+
[Alternative container runtimes > youki](https://docs.docker.com/engine/alternative-runtimes/#youki)
1043+
1044+
##### Configure the default container runtime
1045+
1046+
You can specify either the name of a fully qualified containerd runtime shim,
1047+
or the name of a registered runtime. You can specify the default runtime either
1048+
using the daemon configuration file, or using the `--default-runtime` flag for
1049+
the `dockerd` cli.
8771050

878-
#### Options for the runtime
1051+
When you use the configuration file, the entry uses the following format:
8791052

880-
You can configure the runtime using options specified
881-
with the `--exec-opt` flag. All the flag's options have the `native` prefix. A
882-
single `native.cgroupdriver` option is available.
1053+
```json
1054+
{
1055+
"default-runtime": "io.containerd.runsc.v1"
1056+
}
1057+
```
8831058

884-
The `native.cgroupdriver` option specifies the management of the container's
885-
cgroups. You can only specify `cgroupfs` or `systemd`. If you specify
1059+
When you use the `--default-runtime` CLI flag, use the following format:
1060+
1061+
```console
1062+
$ dockerd --default-runtime io.containerd.runsc.v1
1063+
```
1064+
1065+
#### Run containerd standalone
1066+
1067+
By default, the Docker daemon automatically starts `containerd`. If you want to
1068+
control `containerd` startup, manually start `containerd` and pass the path to
1069+
the `containerd` socket using the `--containerd` flag. For example:
1070+
1071+
```console
1072+
$ sudo dockerd --containerd /run/containerd/containerd.sock
1073+
```
1074+
1075+
#### Configure cgroup driver
1076+
1077+
You can configure how the runtime should manage container cgroups, using the
1078+
`--exec-opt native.cgroupdriver` CLI flag.
1079+
1080+
You can only specify `cgroupfs` or `systemd`. If you specify
8861081
`systemd` and it is not available, the system errors out. If you omit the
8871082
`native.cgroupdriver` option,` cgroupfs` is used on cgroup v1 hosts, `systemd`
8881083
is used on cgroup v2 hosts with systemd available.
@@ -895,16 +1090,19 @@ $ sudo dockerd --exec-opt native.cgroupdriver=systemd
8951090

8961091
Setting this option applies to all containers the daemon launches.
8971092

898-
Also Windows Container makes use of `--exec-opt` for special purpose. Docker user
899-
can specify default container isolation technology with this, for example:
1093+
#### Configure container isolation technology (Windows)
1094+
1095+
For Windows containers, you can specify the default container isolation
1096+
technology to use, using the `--exec-opt isolation` flag.
1097+
1098+
The following example makes `hyperv` the default isolation technology:
9001099

9011100
```console
9021101
> dockerd --exec-opt isolation=hyperv
9031102
```
9041103

905-
Will make `hyperv` the default isolation technology on Windows. If no isolation
906-
value is specified on daemon start, on Windows client, the default is
907-
`hyperv`, and on Windows server, the default is `process`.
1104+
If no isolation value is specified on daemon start, on Windows client,
1105+
the default is `hyperv`, and on Windows server, the default is `process`.
9081106

9091107
### Daemon DNS options
9101108

0 commit comments

Comments
 (0)