X

Debian / Ubuntu Linux 安裝套件的下載暫存路徑

Debian / Ubuntu Linux 預設 APT 下載的暫存目錄 /var/cache/apt

但是若有被修改,可以使用 apt-config 來查詢:

  1. eval $(apt-config shell CACHE Dir::Cache)
  2. eval $(apt-config shell ARCHIVES Dir::Cache::archives)
  3. echo /${CACHE}/${ARCHIVES} # 可以看到完整路徑

Debian / Ubuntu Linux 安裝套件的下載暫存路徑

查詢暫存目錄指令:

  • apt-config shell Cache Dir::Cache
  • apt-config shell Cache Dir::Cache::Archives

在 Docker 安裝套件,在 Cache 資料夾都找不到任何東西,是因為 Docker 有個 docker-clean 設定不存 Cache

  • cat /etc/apt/apt.conf.d/docker-clean
    # Since for most Docker users, package installs happen in "docker build" steps,
    # they essentially become individual layers due to the way Docker handles
    # layering, especially using CoW filesystems. What this means for us is that
    # the caches that APT keeps end up just wasting space in those layers, making
    # our layers unnecessarily large (especially since we'll normally never use
    # these caches again and will instead just "docker build" again and make a brand
    # new image).

    # Ideally, these would just be invoking "apt-get clean", but in our testing,
    # that ended up being cyclic and we got stuck on APT's lock, so we get this fun
    # creation that's essentially just "apt-get clean".
    DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/.deb /var/cache/apt/archives/partial/.deb /var/cache/apt/.bin || true"; };
    APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/.deb /var/cache/apt/archives/partial/.deb /var/cache/apt/.bin || true"; };

    Dir::Cache::pkgcache "";
    Dir::Cache::srcpkgcache "";

    # Note that we do realize this isn't the ideal way to do this, and are always
    # open to better suggestions (https://github.com/debuerreotype/debuerreotype/issues).

  • 想要留套件資料,把這個檔案砍掉即可:rm /etc/apt/apt.conf.d/docker-clean
Tsung: 對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.
Related Post