很多开源的容器镜像都缺乏很多命令,而有时我们又得进行测试,开源的容器镜像大多数是debain系统构建的,本博客介绍如何在容器安装各类常用工具。
进入容器,重新配置debain源为阿里云源:
mv /etc/apt/sources.list /etc/apt/sources.list.bak
tee /etc/apt/sources.list << EOF
deb http://mirrors.aliyun.com/debian stable main contrib non-free
deb http://mirrors.aliyun.com/debian stable-proposed-updates main contrib non-free
deb http://mirrors.aliyun.com/debian stable-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian stable main contrib non-free
deb-src http://mirrors.aliyun.com/debian stable-proposed-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian stable-updates main contrib non-free
EOF
很多容器发觉无ifconfig,netstat命令,其实是缺乏net-tools包:
apt-get update && apt-get install net-tools -y
很多容器发觉无ps命令,其实是缺乏procps包
apt-get update && apt-get install procps -y
安装telnet
apt-get update && apt-get install telnet -y
安装curl
apt-get update && apt-get install curl -y
安装ping
apt-get install inetutils-ping -y
安装vim
apt-get install vim -y