一.最小的鏡像alpine(用于替代Ubuntu的伺服器版本)
- 因CentOS8才有kernel4.18版本,alpine3.9版本kernel為4.19,故選擇kernel4.14的alpine3.8
- https://raw.githubusercontent.com/alpinelinux/docker-alpine/dc10be162e9d2c3f799fde73e25ad30f78ff479b/x86_64/Dockerfile
- https://raw.githubusercontent.com/alpinelinux/docker-alpine/dc10be162e9d2c3f799fde73e25ad30f78ff479b/x86_64/alpine-minirootfs-3.8.4-x86_64.tar.gz
二.建構&運作&使用鏡像
- 将Dockerfile與alpine-minirootfs-3.8.4-x86_64.tar.gz放在同一檔案夾下,執行建構指令:
- 使用鏡像運作容器,容器名為alpine001
podman run -itd --name alpine001 localhost/alpine
- 進入鏡像執行
podman exec -it alpine001 sh
三.alpine内的基礎指令
指令 | 作用 |
---|---|
apk | 安裝軟體,類似于yum |
連按TAB鍵兩次 | 輸出所有可用的指令,都是基礎指令 |
四.apk指令詳解
/ # apk
apk-tools 2.10.1, compiled for x86_64.
Installing and removing packages:
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
System maintenance:
fix Repair package or upgrade it without modifying main dependencies
update Update repository indexes from all remote repositories
upgrade Upgrade currently installed packages to match repositories
cache Download missing PACKAGEs to cache and/or delete unneeded files from cache
Querying information about packages:
info Give detailed information about PACKAGEs or repositories
list List packages by PATTERN and other criteria
dot Generate graphviz graphs
policy Show repository policy for packages
Repository maintenance:
index Create repository index file from FILEs
fetch Download PACKAGEs from global repositories to a local directory
verify Verify package integrity and signature
manifest Show checksums of package contents
Use apk <command> --help for command-specific help.
Use apk --help --verbose for a full command listing.
This apk has coffee making abilities.
apk源配置檔案為:/etc/apk/repositories
建議改為阿裡源
http://mirrors.aliyun.com/alpine/v3.8/main
http://mirrors.aliyun.com/alpine/v3.8/community
要使用apk安裝軟體,需要更新緩存,必須先執行
apk update
指令 | 詳解 |
---|---|
apk list open | 列出符合通配符表達式的軟體 |
apk add openjdk8 | 安裝openjdk8 |