**

以在Docker容器中安装vim为例

**
linux系统没有vim工具太不方便了,我要在docker容器里修改一些文件,所以决定安装下vim。系统是debian。
首先进入容器(前提是容器已经启动):

docker exec -it mysql bash  # mysql是容器名称,换成你自己的

接下来更新下apt-get的源。把下面的命令全部复制粘到容器的控制台执行:

mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
    echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >/etc/apt/sources.list && \
    echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list && \
    echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list && \
    echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list

现在就能安装软件了:

apt-get update && apt-get install vim -y
Logo

更多推荐