Alpine Linux 基于 musl libc(在 Linux 系统调用 API 之上实现的标准 C 库)和 Busybox 构建的 Linux 发行版。其 Docker 镜像仅有 5 MB,非常适合作为基础镜像。

[TOC]

Cmder

安装 Cmder,Windows 下的可移植终端模拟器。

Docker

运行容器:

docker run -it --rm alpine

作为基础镜像:

FROM alpine:3.14
RUN apk add --no-cache mysql-client
ENTRYPOINT ["mysql"]

Alpine Linux

以下内容摘抄于 Alpinx Linux 官方用户手册,和 Docker 无关。

系统安装后置操作

创建普通用户

adduser -h /home/john -s /bin/ash john

权限管理

apk add sudo
echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel
adduser john wheel

通常将 Linux 下具有管理员权限的组叫做 wheel

APK

APK (Alpine Package Keeper),Alpine Linux 下的包管理工具。

apk search: find package (binaries, libraries)

apk search libsqlite3.so
apk search consule
apk search -e vim # exact
apk search -e so:libsqlite3.so.* # so: library, cmd: command, pc: pkg-config file 

apk add: install package

apk add busybox-extras
apk add bash zsh
apk add cmd:bash cmd:zsh
apk add so:libmpack.so.0 # discouraged
apk add pc:msgpack

apk upgrade:update system

apk upgrade

apk info: package description, webpage, installed size

apk info vim

apk del: remove package (including package not used)

apk del vim

remove apk cache:

apk cache clean

OpenRC

init system, rc-service/service (openrc)

apk add openrc

manipulate serivces:

service networking stop
service sshd start
service chronyd status

flags userful for scripts:

  • -c --ifcrashed
  • -N --ifnotstarted
  • -s --ifstarted

On-Boot Services:

rc-update -v
rc-update add sshd default
rc-update add sshd
rc-update delete sshd
rc-update delete chronyd -a

rc-status: system status

  • -c --crashed
  • -l --list (available runlevels)
  • -s --servicelist

参考