Apline Linux是一個(gè)面向安全應(yīng)用的輕量級(jí)Linux發(fā)行版。它采用了musl libc和busybox以減小系統(tǒng)的體積和運(yùn)行時(shí)資源的消耗掸茅,同時(shí)還提供了自己包管理工具apk;
Apline Linux的內(nèi)核都打上了grsecurity/Pax補(bǔ)丁,并且所有的程序都編譯為Postion Independent Executables(PIE)以增強(qiáng)系統(tǒng)的安全性;
Apline Linux的優(yōu)缺點(diǎn)
優(yōu)點(diǎn)
- Apline Linux的Docker鏡像特點(diǎn)就是輕巧(大小只有5M)且有完整的包管理工具炎咖,需要更少的運(yùn)行資源央碟;
缺點(diǎn)
- Apline Linux使用了musl libc,可能和其他發(fā)行版GUN/Linux都使用的glibc實(shí)現(xiàn)會(huì)有些不同吹害;
Apline Linux包管理
Apline Linux使用apk進(jìn)行包管理螟凭,通過apk --help命令查看完整的管理命令,下面列舉常用的命令:
升級(jí)包
apk update # 更新最新本地鏡像源
apk upgrade # 升級(jí)軟件
apk add --upgrade busybox # 指定升級(jí)部分軟件包
安裝包
apk add openssh vim
apk add --no-cache mysql-clinet
apk add docker --update-cache --repository http://mirrors.ustc.edu.cn/alpine/v3.4/main/ --allow-untrusted
卸載刪除包
apk del xxx
search搜索可用的包
apk search
apk search -v 'acf*' # 通過包名搜索
apk search -v -d 'docker' # 通過描述文件搜索
info顯示包信息
apk info # 列出所有已安裝的包
apk info -a zlib # 顯示完整的軟件包信息
apk info --who-owns /sbin/lbu # 顯示指定文件屬于的包
Apline鏡像源
國內(nèi)鏡像源
清華TUNA鏡像源:https://mirror.tuna.tsinghua.edu.cn/alpine/
中科大鏡像源:http://mirrors.ustc.edu.cn/alpine/
阿里云鏡像源:http://mirrors.aliyun.com/alpine/
配置鏡像源
以中科大源為例:在/etc/apk/repositories文件中加入對(duì)應(yīng)源地址就行了它呀,一行一個(gè)地址螺男。
$ vi /etc/apk/repositories
# /media/cdrom/apks
http://mirrors.ustc.edu.cn/alpine/v3.5/main
http://mirrors.ustc.edu.cn/alpine/v3.5/community
Alpine Linux init系統(tǒng)
https://wiki.alpinelinux.org/wiki/Alpine_Linux_Init_System
Alpine Linux使用的是Gentoo一樣的OpenRC init系統(tǒng), 需要注意的是棒厘,docker apline并沒有啟動(dòng)rc init, 如果需要使用, apk add openrc --no-cache
;
-
rc-update: 主要用于不同運(yùn)行級(jí)增加或者刪除服務(wù)
rc-update add docker boot #增加一個(gè)服務(wù) rc-update del docker boot #刪除一個(gè)服務(wù)
-
rc-status: 主要用于運(yùn)行級(jí)的狀態(tài)管理
rc-status #檢查默認(rèn)運(yùn)行級(jí)別的狀態(tài) rc-status -a #檢查所有運(yùn)行級(jí)別的狀態(tài)
-
rc-service: 主用于管理服務(wù)的狀態(tài)
rc-service sshd start #啟動(dòng)一個(gè)服務(wù)。 rc-service sshd stop #停止一個(gè)服務(wù)下隧。 rc-service sshd restart #重啟一個(gè)服務(wù)奢人。
可用的運(yùn)行級(jí)別
- sysinit - Brings up any system specific stuff such as /dev, /proc and optionally /sys for Linux based systems. It also mounts /lib/rc/init.d as a ramdisk using tmpfs where available unless / is mounted rw at boot. rc uses /lib/rc/init.d to hold state information about the services it runs. sysinit always runs when the host first starts and should not be run again.
- boot - Generally the only services you should add to the boot runlevel are those which deal with the mounting of filesystems, set the initial state of attached peripherals and logging. Hotplugged services are added to the boot runlevel by the system. All services in the boot and sysinit runlevels are automatically included in all other runlevels except for those listed here.
- single - Stops all services except for those in the sysinit runlevel.
- reboot - Changes to the shutdown runlevel and then reboots the host.
- shutdown - Changes to the shutdown runlevel and then halts the host.