Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Very slow network performance of Docker containers with host's network

I'm having a problem with sluggish network performance between Docker containers and host's network. I asked this question on the Docker's forum but have received no answers so far.

Problem

Set-up: two Macs on the same local network; the first runs an MQTT broker (mosquitto); the second runs Docker for Mac. Two C++ programs run on the second Mac and exchange data multiple times through the MQTT broker (on the first Mac), using the Paho MQTT C library.

Native run: when I ran the two C++ programs natively, the network performance was excellent as expected. The programs were built with XCode 7.3.

Docker runs: when I ran either of the C++ programs, or both of them, in Docker, the network performance dropped dramatically, roughly 30 times slower than the native run. The Docker image is based on ubuntu:latest, and the programs were built by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609.

I tried to use the host network (--network="host" in Docker run) but it didn't help. I also tried to run the MQTT broker on the second Mac (so that the broker and the containers ran on the same host); the problem persisted. The problem existed on both my work LAN and my home network.

In theory, it could have been that the C++ programs were generally slow in Docker containers. But I doubt this was the case because in my experience, the general performance of C++ code in Docker is about as fast as in the native environment.

Question

What could be the cause of this problem? Are there any settings in Docker that can solve this issue?

like image 357
Truong Avatar asked Jul 24 '16 22:07

Truong


1 Answers

Your problem sounds very similar to this open issue on the Docker for Mac repo. Unfortunately, there doesn't seem to be a known solution, but the discussion in there may be useful. My personal guess at the moment is that the bug lives near the hyperkit virtualization being used on Docker for Mac specifically.

In my case, I was oddly able to bypass this issue by using a different physical router, but I have no idea why it worked. Sadly that's not really a 'solution' though.

I hate that this isn't a great answer, but I wanted to at least share the discussion in the open issue. Good luck and keep us posted.

like image 189
Davis Engeler Avatar answered Oct 24 '22 05:10

Davis Engeler