CentOS Stream release 8 + Docker + MTU
In my CentOS Stream release 8 the size of MTU is set to 1458.
On the other hand, Docker sets it to 1500. This may lead to strange issues with network traffic.
If you want to fix it, there are few things to do.
Make sure to set MTU size inside daemon.json file
> cat /etc/docker/daemon.json { "mtu": 1458 }
once it’s set, restart Docker service
> sudo systemctl stop docker > sudo systemctl stop docker.socket > sudo systemctl start docker
MTU of your Docker bridge should be now OK
> docker network inspect bridge [ { ... ... "Options": { "com.docker.network.bridge.default_bridge": "true", "com.docker.network.bridge.enable_icc": "true", "com.docker.network.bridge.enable_ip_masquerade": "true", "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", "com.docker.network.bridge.name": "docker0", "com.docker.network.driver.mtu": "1458" }, "Labels": {} } ]
however, it’s not over. It may happen that docker0 is still not quite correct as seen in the system
> ip link ... 62: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default link/ether aa:aa:aa:aa:aa:aa brd ff:ff:ff:ff:ff:ff
In order to fix the MTU here, you have to use ip command
> ip link set dev docker0 mtu 1458
and now, it’s reported as it should be.
> ip link ... 62: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1458 qdisc noqueue state DOWN mode DEFAULT group default link/ether aa:aa:aa:aa:aa:aa brd ff:ff:ff:ff:ff:ff
That’s it. Now you should no longer experience stalled transfers while using curl or maven for downloading things inside the Docker container.