标签:packages 步骤 ali 官方 roo proc sim stat etc
alpine轻量级基于busybox的发行版,特别适合基于docker的base images.
特点:
small、simple、secure
https://alpinelinux.org/ //官方发行版本
https://pkgs.alpinelinux.org/packages?name=&branch=edge //apk package
在hub.docker.com官方仓库中默认shell是sh,我还是必须喜欢bash
https://hub.docker.com/_/alpine
1、安装bash相关pkg
2、修改root账户默认shell
3、修改登录shell后的光标栏(PS1)
4、覆盖默认进去shell(sh-->bash)
Dockerfile
FROM alpine:3.7 MAINTAINER mvpbang mvpbang@qq.com ###alpine+bash ADD .bashrc /root/ RUN set -x apk update && apk add --no-cache bash bash-doc bash-completion && sed -i ‘s/ash/bash/g‘ /etc/passwd && source /root/.bashrc CMD ["/bin/bash"]
.bashrc
export HISTTIMEFORMAT="%d/%m/%y %T " export PS1=‘\u@\h:\W \$ ‘ alias ll=‘ls -alF‘ alias ls=‘ls --color=auto‘ source /etc/profile.d/bash_completion.sh
docker build -t alpine:v1 .
[root@mvp-dd tmp]# docker run --rm -it alpine:v1 root@522065c46217:/ # root@522065c46217:/ # root@522065c46217:/ # ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 12: eth0@if13: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP link/ether 02:42:ac:11:00:03 brd ff:ff:ff:ff:ff:ff inet 172.17.0.3/16 brd 172.17.255.255 scope global eth0 valid_lft forever preferred_lft forever
注意:由于默认容器启动执行的 /bin/bash,如果引用此镜像未在启动 -it,容器启动完毕后自动退出(no process stop)
标签:packages 步骤 ali 官方 roo proc sim stat etc
原文地址:https://www.cnblogs.com/xiaochina/p/10480774.html