Dockerfileハマったことリスト
rm -rf /var/lib/apt/lists/*
apt キャッシュをクリーンにし、 /var/lib/apt/lits を削除することで、イメージのサイズを減らします。 RUN 命令は apt-get update から開始されるので、 apt-get install でインストールされるパッケージは、常に新鮮なものです。
apt-get clean
Official Debian and Ubuntu images automatically run apt-get clean, so explicit invocation is not required.
The same as above, except it removes all packages from the package cache. This may not be desirable if you have a slow Internet connection, since it will cause you to redownload any packages you need to install a program.
The package cache is in /var/cache/apt/archives . The command
du -sh /var/cache/apt/archives
will tell you how much space cached packages are consuming.
pip install --no-cache-dir scipy
pip には残念ながらキャッシュディレクトリを消すコマンドが用意されていません。一番簡単なのは pip install する時には cache を作らないようにする方法です。pip>=6 であれば no-cache-dir option をつけるとキャッシュせずに install が行われます。