You should use a caching proxy (fe Http Replicator , squid-deb-proxy ...) or apt-cacher-ng for Ubuntu to cache installation packages. I think you can install this software on the host machine.
EDIT:
Option 1 - http proxy caching is a simpler method with a modified Docker file:
> cd ~/your-project > git clone https://github.com/gertjanvanzwieten/replicator.git > mkdir cache > replicator/http-replicator -r ./cache -p 8080 --daemon ./cache/replicator.log --static
add to your Docker file (before the first RUN line):
ENV http_proxy http:
You should clear the cache from time to time.
Option 2 - transparent proxy caching, without modifying the Docker file:
> cd ~/your-project > curl -o r.zip https://codeload.github.com/zahradil/replicator/zip/transparent-requests > unzip r.zip > rm r.zip > mv replicator-transparent-requests replicator > mkdir cache > replicator/http-replicator -r ./cache -p 8080 --daemon ./cache/replicator.log --static
You need to run the replicator as a user (not root!).
Set up transparent redirection:
> iptables -t nat -A OUTPUT -p tcp -m owner ! --uid-owner <replicator-user> --dport 80 -j REDIRECT --to-port 8080
Disable redirection:
> iptables -t nat -D OUTPUT -p tcp -m owner ! --uid-owner <replicator-user> --dport 80 -j REDIRECT --to-port 8080
This method is the most transparent and general, and your Dockerfile does not need to be changed. You should clear the cache from time to time.
Jiri Feb 28 '14 at 8:31 2014-02-28 08:31
source share