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.
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 ...
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With