用于Alpine Linux的“ --update add”命令的说明

Kur*_*eek 8 linux docker alpine-linux

我想了解Dockerfile https://hub.docker.com/r/rdsubhas/tor-privoxy-alpine/~/dockerfile/,其中包含一个RUN执行官

apk --update add privoxy tor@testing runit@testing
Run Code Online (Sandbox Code Playgroud)

我想检查一下我对apk命令用法的理解,因此我尝试如下在Alpine环境中打开终端:

docker run -it --rm alpine:latest /bin/ash
Run Code Online (Sandbox Code Playgroud)

之后,我只是跑去apk看看它的用法:

/ # apk
apk-tools 2.6.8, compiled for x86_64.

usage: apk COMMAND [-h|--help] [-p|--root DIR] [-X|--repository REPO]
           [-q|--quiet] [-v|--verbose] [-i|--interactive] [-V|--version]
           [-f|--force] [-U|--update-cache] [--progress] [--progress-fd FD]
           [--no-progress] [--purge] [--allow-untrusted] [--wait TIME]
           [--keys-dir KEYSDIR] [--repositories-file REPOFILE] [--no-network]
           [--no-cache] [--arch ARCH] [--print-arch] [ARGS]...

The following commands are available:
  add       Add PACKAGEs to 'world' and install (or upgrade) them, while
            ensuring that all dependencies are met
  del       Remove PACKAGEs from 'world' and uninstall them
  fix       Repair package or upgrade it without modifying main dependencies
  update    Update repository indexes from all remote repositories
  info      Give detailed information about PACKAGEs or repositores
  search    Search package by PATTERNs or by indexed dependencies
  upgrade   Upgrade currently installed packages to match repositories
  cache     Download missing PACKAGEs to cache and/or delete unneeded files
            from cache
  version   Compare package versions (in installed database vs. available) or
            do tests on literal version strings
  index     Create repository index file from FILEs
  fetch     Download PACKAGEs from global repositories to a local directory
  audit     Audit the directories for changes
  verify    Verify package integrity and signature
  dot       Generate graphviz graphs
  policy    Show repository policy for packages
  stats     Show statistics about repositories and installations

Global options:
  -h, --help              Show generic help or applet specific help
  -p, --root DIR          Install packages to DIR
  -X, --repository REPO   Use packages from REPO
  -q, --quiet             Print less information
  -v, --verbose           Print more information (can be doubled)
  -i, --interactive       Ask confirmation for certain operations
  -V, --version           Print program version and exit
  -f, --force             Do what was asked even if it looks dangerous
  -U, --update-cache      Update the repository cache
  --progress              Show a progress bar
  --progress-fd FD        Write progress to fd
  --no-progress           Disable progress bar even for TTYs
  --purge                 Delete also modified configuration files (pkg
                          removal) and uninstalled packages from cache (cache
                          clean)
  --allow-untrusted       Install packages with untrusted signature or no
                          signature
  --wait TIME             Wait for TIME seconds to get an exclusive repository
                          lock before failing
  --keys-dir KEYSDIR      Override directory of trusted keys
  --repositories-file REPOFILE Override repositories file
  --no-network            Do not use network (cache is still used)
  --no-cache              Read uncached index from network
  --arch ARCH             Use architecture with --root
  --print-arch            Print default arch and exit

This apk has coffee making abilities.
Run Code Online (Sandbox Code Playgroud)

问题是,我--update在此文档中看不到该选项(仅--update-cache)。

我怀疑这apk --update add [package]只是apk update后面的简写apk add [package]。有人可以确认吗?

小智 20

https://github.com/gliderlabs/docker-alpine/pull/503

apk --update 标志实际上是 --update-cache。

apk使用getopt_long(3), https://github.com/alpinelinux/apk-tools/blob/v2.10.3/src/apk.c#L574

因此,--update 标志仅由 getopt_long 从 --update-cache 缩写而来。

如果缩写是唯一的或者与某些定义的选项完全匹配,则可以缩写长选项名称。

  • 这应该是选定的答案。 (2认同)

use*_*097 11

简而言之:

To get the latest list of available packages, use the update command.

它类似于apt-get update您之前所做的 Debian apt-get install my_package

来自https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Update_the_Package_list

提炼

更新包列表

随着软件包的添加和升级,远程存储库会发生变化。要获取可用软件包的最新列表,请使用 update 命令。该命令从每个存储库下载 APKINDEX.tar.gz 并将其存储在本地缓存中,通常是 /var/cache/apk/、/var/lib/apk/ 或 /etc/apk/cache/。

更新

提示:如果使用远程存储库,最好在执行添加或升级命令之前进行更新。这样您就知道您正在使用最新的可用软件。

  • 我知道了。`apk --update add [package]` 是否只是先执行 `apk update` 然后执行 `apk add [package]` 的简写? (16认同)
  • 正是如此 (10认同)
  • > 添加`--update-cache`,或者简称`-U`切换到另一个apk命令,如`apk --update-cache update`或`apk -U add ...`,该命令具有与在其他 apk 命令之前首先运行 `apk update` 的效果相同。https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Update_the_Package_list (2认同)