• 基于Ubuntu20.04.01

    1.docker容器内apt换源

    1
    2
    3
    4
    5
    6
    7
    #备份源文件
    mv /etc/apt/sources.list /etc/apt/sources.list.bak
    #导入源地址
    cat <<EOF >/etc/apt/sources.list
    deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
    deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
    EOF

    or

    1
    2
    3
    4
    5
    6
    cat <<EOF >/etc/apt/sources.list
    deb http://mirrors.163.com/debian/ jessie main non-free contrib
    deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib
    deb-src http://mirrors.163.com/debian/ jessie main non-free contrib
    deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib
    EOF
    1
    2
    apt update
    apt-get update

    2.docker容器内安装基础命令

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    #安装yum
    apt-get install yum -y
    #安装vim
    apt-get install vim -y
    #安装ping
    apt install iputils-ping -y
    #安装ps
    apt-get install procps -y
    #安装ifconfig
    apt-get install net-tools
    #安装sudo
    apt-get install sudo
    #安装crontab
    apt-get install cron
    #查看cron的状态
    service cron status
    #重启crontab服务
    service cron restart