在一个 ubuntu 容器内,换源,安装和运行( ifconfig, ps,ping)

要修改容器内的ubuntu 的源, (假设该容器名称为 ubuntu01 )步骤如下:

  1. 进入容器
    docker exec -it ubuntu01 /bin/bash
  2. 修改源, 运行如下命令
    cat > /etc/apt/sources.list <<-EOF
    deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    EOF
  3. 安装软件 (ifconfig, ps, ping这些命令)
    apt-get clean
    apt-get autoremove --purge
    apt update
    apt -y install net-tools procps iputils-ping

    net-tools :为了使用ifconfig

    procps:为了使用ps

    iputils-ping:为了使用ping

posted on 2021-01-27 15:19  老邓的成长空间  阅读(98)  评论(0)    收藏  举报