mediasoup: Docker and io_uring don't work together - add prebuilt binary without liburing

Motivation

When installing mediasoup in a Docker container (on the linux/amd64 platform) the mediasoup worker will crash with this error failure exit: io_uring_queue_init() failed: Operation not permitted.

Containerd has removed support for io_uring as it has been deemed unsafe. The rationale for this decision is explained here: https://github.com/containerd/containerd/issues/9048

Current Workarounds

There are two options to work around this currently: (1) force the local build of mediasoup without io_uring, and (2) override the default seccomp profile.

Local build

This is the only viable option at the moment. We can force the npm postinstall to build the worker locally by adding these two environment variables before the npm install command:

# don't download the prebuilt binary
ENV MEDIASOUP_SKIP_WORKER_PREBUILT_DOWNLOAD="true"
# build without io_uring
ENV MESON_ARGS="-Dms_disable_liburing=true"

However, this obviously slows down the build process fairly significantly. But it works and has no security cost.

Seccomp Profile (BAD idea)

We can manually override the seccomp profile by passing --security-opt with the docker run command. I have not been able to find the exact syscalls that cause the issue, but allowing all syscalls by default works (as mentioned here https://github.com/moby/moby/issues/39396#issuecomment-504642822).

This will make mediasoup work again, but at a great security cost – the syscalls were disallowed for a reason.

I DON’T THINK THIS IS A GOOD IDEA. I’m just adding this in case someone stumbles across this solution as I did.

Feature Request

Even though the first method works, it is less than ideal. However, I understand that io_uring brings some performance benefit which justifies its use in general. Therefore, another prebuilt binary should exist without io_uring when using Docker.

I don’t know if it’s possible to detect a docker build automatically and reliably (maybe this helps?) but that would obviously be the best case. Otherwise an environment variable to switch between the version with and without io_uring would be the next best thing.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (12 by maintainers)

Commits related to this issue

Most upvoted comments

The solution (as of v3.14.11) is to use disableLiburing: true in WorkerSettings object passed to createWorker()

This is to disable io_uring even if it works.

And, in the future, #1445 (which will probably be deployed with v3.14.12) io_uring won’t be used in runtime checks?

This is to not fail if io_uring is supported by the kernel but is disabled at kernel layer.