• 【docker】容器无法使用vi等命令,无法联网,无法换源如何解决?


    解决方案:

    在宿主机某个位置上创建文件: sources.list
    然后修改文件,写入清华源

    # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
    
    # deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
    # # deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
    
    # 预发布软件源,不建议启用
    # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
    # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    执行 docker ps查询容器名;
    在这个sources.list所在位置打开命令行。执行以下命令,将宿主机的sources.list拷贝到容器中

    docker cp sources.list 容器名:/etc/apt
    
    • 1

    然后进入容器里面再更新源

    docker exec -it 容器名 /bin/bash
    ...
    apt-get update
    
    • 1
    • 2
    • 3

    等更新完后,可以sudo apt install ***来安装所需库

  • 相关阅读:
    【毕业季·进击的技术er】绕树三匝,何枝可依?
    httplib库的安装以及使用
    adb shell pm path packageName
    webpack构建自己的npm开源包
    DNS域名解析----分离解析、多域名解析、父域与子域
    【ORACLE】ORA-00972:标识符过长
    基于SqlSugar的开发框架循序渐进介绍(17)-- 基于CSRedis实现缓存的处理
    【jmeter 5.5】 完全手册
    python中三目运算符、推导式 ## 17
    【Linux网络编程】服务器程序框架
  • 原文地址:https://blog.csdn.net/SingDanceRapBall/article/details/133949839