alpine 系统
Alpine 的意思是“高山的”,比如 Alpine plants高山植物,Alpine skiing高山滑雪、the alpine resort阿尔卑斯山胜地。
Alpine Linux 网站首页注明“Small!Simple!Secure!Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox.”概括了以下特点:
小巧:基于Musl libc和busybox,和busybox一样小巧,最小的Docker镜像只有5MB;
安全:面向安全的轻量发行版;
简单:提供APK包管理工具,软件的搜索、安装、删除、升级都非常方便。
适合容器使用:由于小巧、功能完备,非常适合作为容器的基础镜像。
创建用户和组
adduser
-h #创建家目录
-g #用户的详细信息
-s #登录shell
-G #组
-S #创建系统用户
-D #不分配密码
-H #不创建家目录
-u #UID
-k #创建框架目录
删除用户
deluser
alpine没有使用fedora的systemctl来进行服务管理,使用的是RC系列命令:
rc-update //主要用于不同运行级增加或者删除服务
rc-status //主要用于运行级的状态管理
rc-service //主用于管理服务的状态
rc-status -a //列出系统所有服务
官方 Alpine 镜像的文档:http://gliderlabs.viewdocs.io/docker-alpine/
更新国内源
Alpine的源文件为:/etc/apk/repositories
,默认的源地址为:http://dl-cdn.alpinelinux.org/
可以编辑源文件 /etc/apk/repositories
的方式,
使用国内阿里云的源,文件内容为:
https://mirrors.aliyun.com/alpine/v3.6/main/
https://mirrors.aliyun.com/alpine/v3.6/community/
如果采用中国科技大学的源,文件内容为:
https://mirrors.ustc.edu.cn/alpine/v3.6/main/
https://mirrors.ustc.edu.cn/alpine/v3.6/community/
Dockerfile使用alpine系统制作haproxy镜像
结构:
[root@localhost haproxyalpine]# pwd
/haproxyalpine
[root@localhost haproxyalpine]# tree .
.
├── Dockerfile
└── files
├── haproxy-2.4.0.tar.gz
├── haproxycfg.sh
├── install.sh
└── sysctl.conf
1 directory, 5 files
[root@localhost haproxyalpine]# ls
Dockerfile files
查看需要的配置
[root@localhost haproxyalpine]# cat Dockerfile
FROM alpine
LABEL MAINTAINER "[email protected]"
ENV version 2.4.0
ADD files/haproxy-${
version}.tar.gz /tmp/
ADD files/install.sh /tmp/
ADD files/haproxycfg.sh /tmp/
ADD files/sysctl.conf /tmp/
RUN /tmp/install