Extremely slow apt-get update on Debian Jessie

I was fiddling around with the phpdocker.io service. I generated a PHP 5.6 image (phpdockerio/php56-fpm). When I tried to run it, the following line was extremely slow:

RUN apt-get update \

&& apt-get -y –no-install-recommends install php5-mysql php5-gd php5-imagick \

&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

First I thought that it is completely frozen, as it didn’t show any progress. Then I realized that it is just extremely slow as it printed a line after an hours or so. Upon further analysis I found this bug: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1332440. Because of other containers I had a high number for ulimit configured.

I then realized that it was pretty trivial to fix it. I just had to lower the ulimit temporarely. Doing this made it possible to run the command in a couple of seconds:

RUN ulimit -n 10000 && apt-get update \

&& apt-get -y –no-install-recommends install php5-mysql php5-gd php5-imagick \

&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

Leave a comment

Your email address will not be published. Required fields are marked *