Alpine linux apk 命令使用

更新索引

$ apk update

fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
v3.14.8-65-g0f3285f2cf [https://dl-cdn.alpinelinux.org/alpine/v3.14/main]
v3.14.8-66-ge9853dea68 [https://dl-cdn.alpinelinux.org/alpine/v3.14/community]
v20220809-6223-gb7f2956912 [http://nl.alpinelinux.org/alpine/edge/main]
v20220809-6223-gb7f2956912 [http://nl.alpinelinux.org/alpine/edge/testing]
v20220809-6223-gb7f2956912 [http://nl.alpinelinux.org/alpine/edge/community]
OK: 38705 distinct packages available

从远程镜像源中更新本地镜像源索引,update 命令会从各个镜像源列表下载 APKINDEX.tar.gz 并存储到本地缓存,一般在 /var/cache/apk/ (Alpine 在该目录下)

安装软件包

apk add vim openssh

apk add --no-cache mysql-client

apk add docker --update-cache \
--repository http://mirrors.ustc.edu.cn/alpine/v3.4/main/ --allow-untrusted

安装指定版本软件包

apk add asterisk=1.6.0.21-r0

apk add 'asterisk<1.6.1'

apk add 'asterisk>1.6.1

卸载软件包

apk del openssh openntp vim

搜索软件包

搜索所有可用软件包

apk search
apk search -v

通过软件包名称搜索

apk search -v 'acf*'

通过描述文件查找特定的软件包

apk search -v -d 'docker'

查看包信息

列出所有已安装的软件包

apk info 

显示完整的软件包信息

apk info -a zlib

显示指定文件属于的包

apk info --who-owns /sbin/lbu