Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download speed for pip install inside docker container very slow

Tags:

docker

pip

While creating a docker image from a dockerfile or being inside the created container, pip install <package> in a conda environment is super slow.

The download speed hugely differs if I do the same without docker. I tried to change the mirror pip install -i http:pypi.doubanio.com/simple <package> and can gain slight improvements, but still different inside and outside of docker. Testing the download speed inside the container via curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python - gives me the expected good results.

like image 885
André Betz Avatar asked Nov 11 '17 13:11

André Betz


People also ask

How do I make pip install faster?

Going (very slightly) faster by disabling the version check On startup pip may check if you're running the latest version or not, and print a warning if you're not. You can disable this check like so: pip --disable-pip-version-check install ...

Why is my Docker build taking so long?

If your Docker image builds takes a long time downloading dependencies, it's a good idea to check whether you're installing more than you need to. First, check if you might be downloading development dependencies which are not needed in your image at all.

What is the flag in pip install?

The --user flag to pip install tells Pip to install packages in some specific directories within your home directory. This is a good way to have your own default Python environment that adds to the packages within your system directories, and therefore, does not affect the system Python installation.


1 Answers

I suggest building with the --network host when running docker build. This will guarantee the RUN instructions to use the host network directly. That way you will be sure that slowness is not related to docker.

like image 136
yamenk Avatar answered Oct 16 '22 09:10

yamenk