how to switch docker runtime between runc and oci
This is how I changed the default runtime from runc to crun on Ubuntu.
Simply edit ~/.config/docker/daemon.json
, and add crun
to the list of runtimes, then set crun
to be the default runtime.
{
"default-runtime": "crun",
"runtimes": {
"crun": {
"path": "/usr/bin/crun"
}
}
}
Now restart docker service (systemctl restart --user docker
)
Note: If you are not running docker in rootless mode, you will need to instead edit /etc/docker/daemon.json
.
Sources
https://github.com/containers/crun/issues/37
In dockerd, there is the option:
--default-runtime string Default OCI runtime for containers (default "runc")
This is easier to configure in the /etc/docker/daemon.json file
{
"default-runtime": "runc"
}
And then from systemd, you can apply the change with a reload (no need to restart the engine and stop running containers):
systemctl reload docker
Note that a change in the daemon may not affect already created containers, so you'll likely need to create new containers to see the effect of this change.
For changing the runtime on a single container, you can do that from docker run
. There is the following option (visible in docker run --help
):
--runtime string Runtime to use for this container
The compose file has a similar runtime: runc syntax.
I'm not quite sure what docker meant by oci vs runc back when this question was asked, it was probably differentiating between a built-in runtime in the docker engine when they were forking off the runc code. That has long finished and you'll only see runc and containerd.runc runtimes in current docker installs. The reason the wording is confusing is because runc is an OCI project.