How to increase UDP buffer size on Docker Desktop

h0n9
2 min readAug 11, 2022

--

Docker Desktop

Docker Desktop runs containers on its host virtual machine (VM). It’s highly recommended to read The Magic Behind the Scenes of Docker Desktop if you’d like to learn further more. The UDP buffer size of a container depends on its host VM. This means that the buffer size can only be changed inside the host machine.

Step-by-Step

Connect to the host VM

In fact, there is no official way to interact or connect to the host VM. However, there is a special way to do this using the Docker container.

We are going to use justincormack/nsenter1 Docker image. Please refer to the ‘So what is this good for’ section of the repository’s README.md to understand how it works.

$ docker run -it --rm --privileged --pid=host justincormack/nsenter1
/ #

Voilà.
Now you’re inside the host VM.

Set UDP buffer size

/ # sysctl -w net.core.rmem_max=262143
/ # sysctl -w net.core.rmem_default=262143

That’s it.

These commands allows to increse the read buffer memory max and default to 262143 (256k — 1) from defaults of max=131071 (128k — 1) and default=65535 (64k — 1), according to the official Linux Kernel documentiation: Resolving Slow UDP Traffic.

Please follow me to get notified of new posts as soon as possible !

--

--