Alpine

alpine 镜像

进入 alpine

$ docker run -it --rm alpine:3.12.3

# 别名
/ $ alias ll='ls -l'

apk 包管理

镜像加速

$ cat /etc/apk/repositories
http://dl-cdn.alpinelinux.org/alpine/v3.12/main
http://dl-cdn.alpinelinux.org/alpine/v3.12/community

# 改为国内镜像地址
$ sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories

# ❤ 本地缓存地址
$ ls -al /var/cache/apk/

常用命令

# 帮助
$ apk --help
# 子命令帮助
$ apk add --help

# 安装
$ apk add curl

# 卸载
$ apk del curl

Dockerfile

FROM alpine:3.12.3

# 替换国内源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
# 更新
RUN apk update && apk upgrade 
# curl https
RUN apk add ca-certificates && update-ca-certificates && apk add curl
# 删除缓存
RUN rm -rf /var/cache/apk/*

#
WORKDIR /opt

...

Read More