首页 > 其他分享 >解决docker环境apt-get命令太慢问题

解决docker环境apt-get命令太慢问题

时间:2023-03-31 11:37:11浏览次数:44  
标签:RUN get list apt sources sed docker debian

最近学习doris,准备在本地使用docker搭建一个环境,doris文档提供Dockfile中有这么一段:

RUN apt-get update && \
    apt-get install -y default-mysql-client && \
    apt-get clean && \
    mkdir /opt/apache-doris && \
    cd /opt && \
    mv apache-doris-be-1.2.3-bin-x86_64 /opt/apache-doris/be

在docker构建时,上面的命令死活构建不了,问过度娘才知道国内访问debian特别慢,我们可以使用国内的镜像,如阿里就提供了各种各样的镜像

第一步:确定debian的版本,docker构建的时候会有一些地址输出,里面会有stretch、bullseye字样(如下图),这就是版本信息

第二步:打开阿里镜像网站,根据版本确定怎么修改

第三步:在Dockerfile使用sed命令,修改/etc/apt/sources.list,在apt-get命令前添加如下信息

RUN sed -i "1ideb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib" /etc/apt/sources.list
RUN sed -i "2ideb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib" /etc/apt/sources.list
RUN sed -i "3ideb https://mirrors.aliyun.com/debian-security/ bullseye-security main" /etc/apt/sources.list
RUN sed -i "4ideb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main" /etc/apt/sources.list
RUN sed -i "5ideb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" /etc/apt/sources.list
RUN sed -i "6ideb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" /etc/apt/sources.list
RUN sed -i "7ideb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" /etc/apt/sources.list
RUN sed -i "8ideb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" /etc/apt/sources.list

提示:RUN sed -i "1ixxx" aaa表示 修改aaa文件,在第1行前插入xxx信息,具体自行查看sed命令

修改后的效果如下:

做完上面操作了,我们重新执行docker build,apt-get命令就快多了

标签:RUN,get,list,apt,sources,sed,docker,debian
From: https://www.cnblogs.com/zhi-leaf/p/17275726.html

相关文章

  • three.js 使用 getWorldPosition 获取世界坐标
    记录一下项目中的需求,组合后旋转,解组后需要模型位置为旋转后位置disCombinationModel(ModelArry,type){//判断是否有选中if(ModelArry.length===1){constob=ModelArry[0]//判断是否是组合if(ob.typeName==='combination'){......
  • ssh连接docker容器
    1、dockerpull镜像2、查看镜像列表dockerimages3、运行镜像(10.x.x.x是主机ip,/usr/sbin/init可在docker里启动服务,privileged特权容器)dockerrun-itd--privileged=true-p10.x.x.x:9996:22docker.io/ansible/centos7-ansible/usr/sbin/init4、dockerps查看镜......
  • 「高频必考」Docker&K8S面试题和答案
    先送福利:Go如何自动解压缩包?|文末送书Docker如何在Docker容器内部访问主机上的服务?可以通过设置主机网络模式,使用--net=host参数来访问主机上的服务。这样,容器和主机将共享一个网络命名空间,容器将可以直接访问主机上的服务。如何在Docker容器中运行多个进程?Docker推荐每个容......
  • 时钟小程序 所用类qwidget QTime Qpalette
    DigiClock::DigiClock(QWidget&nbsp;*parent) :&nbsp;QLCDNumber(parent){ //设置时钟背景 QPalette&nbsp;p&nbsp;=&nbsp;palette();<br/>//设置调色板颜色QPalette::Window设置背景色 p.setColor(QPalette::Window,&nbsp;Qt::blue);<br/>......
  • docker镜像清理
    stop_container_count=$(dockerps-a|grep"Exited"|awk'{print$1}'|wc-l);\if[$stop_container_count-gt0];\then\dockerstop$(dockerps-a|grep"Exited"|awk'{print$1}');\echo's......
  • CentOS7.6安装Docker
    CentOS7.6安装Docker20.10移除现有dockersudoyumremovedocker\docker-client\docker-client-latest\docker-common\docker-latest\docker-latest-logrotate\......
  • Docker安装Oracle11g
    拉取镜像#拉取镜像dockerpullregistry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g#查看镜像dockerimages镜像比较大(6.9G),可能拉取时间会很久,需要耐心等待创建容器dockerrun-d-p1521:1521--nameoracleregistry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g#......
  • Docker 轻量级可视化工具 Portainer
    1.概述Portainer是一款轻量级的应用,它提供了图形化界面,用于方便地管理Docker环境,包括单机环境和集群环境。官网:https://www.portainer.io/2.在Docker镜像仓库查找Portainer镜像dockerhub镜像仓库3.拉取Portainer镜像#拉取nginx镜像dockerpullportainer......
  • docker desktop k8s错误Unable to connect to the server: EOF
    问题当使用DockerDesktop开启Kubernetes之后,在终端执行命令kubectlgetnodes时,出现以下错误:Unabletoconnecttotheserver:EOF根因分析终端执行命令kubectlcluster-info,输出如下:Tofurtherdebuganddiagnoseclusterproblems,use'kubectlcluster-infod......
  • docker build 构建时 alpinelinux 镜像权限错误
    问题使用dockerbuild构建镜像时,发生一个错误:“ERROR:https://dl-cdn.alpinelinux.org/alpine/v3.15/main:Permissiondenied”。部分日志如下:[2023-03-3014:51:12]Step3/16:RUNapkupdate&&apkupgrade&&apkaddmusl-devmakegccpython3[2023-03-3014:51:12......