当前位置: 首页 > article >正文

如何解决 Docker 下载 mcr.microsoft.com 镜像慢的办法

一、介绍

    MCR(Miscrosoft Container Registry) 加速器,助你在中国大陆急速下载 netcore 相关的 docker 镜像。

二、解决办法。

    1、如何使用

      至少三种方法进行加速:
        使用 docker-mcr (推荐)
        拉取国内服务器上的镜像
        使用 DockerHub 加速器

      注意,无论采用什么方式,请先确保本地的 docker 已经正常可用。

    2、使用 docker-mcr (推荐)

      docker-mcr 是一个 dotnet core global tool,简单几步,便可以进行安装和使用。

      进入 dotnet 页面,下载并安装 netcore 3.1 SDK 或者 Net 5.0,如果没有安装 SDK,是无法使用 dotnet 命令的。

      



      安装完毕后打开控制台运行以下命令:

#dotnet tool install newbe.mcrmirror -g

     如果已经安装,会提示已经安装。
      


      现在,假如需要拉取 mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim ,则运行以下命令:#docker-mcr -i mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim
      


      等待完成之后,便可以在本地看到已经拉取完毕的镜像。
      


      您可以运行 docker-mcr --help 来查看更多的参数配置方式。

      命令:#docker-mcr --help
      



      如果您曾经安装过 newbe.mcrmirror,您需要使用 dotnet tool update newbe.mcrmirror -g命令来进行升级,确保最佳的体验。

      命令:#dotnet tool update newbe.mcrmirror -g
      


 

    3、拉取国内服务器上的镜像

      加速的本质是因为我将镜像推送到了国内的服务器,目前在以下服务器均存在镜像:

            阿里云:registry.cn-hangzhou.aliyuncs.com/newbe36524
            腾讯云:ccr.ccs.tencentyun.com/mcr_newbe36524

      以下以阿里云为例进行说明,假设需要拉取 【aspnet:3.1-buster-slim】 和【sdk:3.1-buster】

      则拼接上面的前缀,则得到地址【registry.cn-hangzhou.aliyuncs.com/newbe36524/aspnet:3.1-buster-slim】 和【registry.cn-hangzhou.aliyuncs.com/newbe36524/sdk:3.1-buster】 。

      然后,为了不修改默认的 Dockerfile 您可以运行以下命令:
 

3.1 版本
#docker pull registry.cn-hangzhou.aliyuncs.com/newbe36524/aspnet:3.1-buster-slim
#docker tag registry.cn-hangzhou.aliyuncs.com/newbe36524/aspnet:3.1-buster-slim mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim5         
#docker pull registry.cn-hangzhou.aliyuncs.com/newbe36524/sdk:3.1-buster
#docker tag registry.cn-hangzhou.aliyuncs.com/newbe36524/sdk:3.1-buster mcr.microsoft.com/dotnet/core/sdk:3.1-buster

ASP.NET 3.1 镜像
       


        



ASP.NET SDK 3.1 镜像
        

       

这样你就成功的在本地得到了 【mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim】和【mcr.microsoft.com/dotnet/core/sdk:3.1-buster】 镜像。
       当然,你也可以直接把 【registry.cn-hangzhou.aliyuncs.com/newbe36524/aspnet:3.1-buster-slim】和【registry.cn-hangzhou.aliyuncs.com/newbe36524/sdk:3.1-buster】 写入到你的 Docker file 中。

5.0 版本

#docker pull registry.cn-hangzhou.aliyuncs.com/newbe36524/aspnet:5.0-buster-slim
#docker tag registry.cn-hangzhou.aliyuncs.com/newbe36524/aspnet:5.0-buster-slim mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim
#docker pull registry.cn-hangzhou.aliyuncs.com/newbe36524/sdk:5.0-buster-slim
#docker tag registry.cn-hangzhou.aliyuncs.com/newbe36524/sdk:5.0-buster-slim mcr.microsoft.com/dotnet/core/sdk:5.0-buster-slim

ASPNET SDK 5.0 镜像        
        

       


        

        
      
       这样你就成功的在本地得到了【mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim】 和 【mcr.microsoft.com/dotnet/core/sdk:5.0-buster-slim】 镜像。
       当然,你也可以直接把 【registry.cn-hangzhou.aliyuncs.com/newbe36524/aspnet:5.0-buster-slim】 和 【registry.cn-hangzhou.aliyuncs.com/newbe36524/sdk:5.0-buster-slim】写入到你的 Dockerfile 中。


    4、使用 DockerHub 加速器(这个开始有点慢)

      我也将镜像推送到了 DockerHub ,所以正常来说,在中国大陆使用 DockerHub 加速器也可以达到加速的效果。

      规则,mcr.microsoft.com/dotnet/cre/{name}:{tag} -> newbe36524/{name}:{tag}

      ASP.NET 3.1 镜像

        【1】、命令:#docker pull newbe36524/aspnet:3.1-buster-slim

            



        【2】、命令:#docker tag newbe36524/aspnet:3.1-buster-slim mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim

            



        【3】、命令:#docker images

            


 

复制代码

1       #docker pull newbe36524/aspnet:3.1-buster-slim
2       #docker tag newbe36524/aspnet:3.1-buster-slim mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim


 3       #docker pull newbe36524/sdk:3.1-buster
  4           #docker tag newbe36524/sdk:3.1-buster mcr.microsoft.com/dotnet/core/sdk:3.1-buster

复制代码


      ASP.NET 3.1 镜像
        
        【1】、命令:#docker pull newbe36524/sdk:3.1-buster
        
            



        【2】、命令:#docker tag newbe36524/sdk:3.1-buster mcr.microsoft.com/dotnet/core/sdk:3.1-buster
        
            



        【3】、命令:#docker images

            




      这样你就得到了【mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim】和【mcr.microsoft.com/dotnet/core/sdk:3.1-buster】 镜像。当然,你也可以直接把 【newbe36524/aspnet:3.1-buster-slim】和【newbe36524/sdk:3.1-buster】 写入到你的 Dockerfile 中。在此之前,请确保你正确配置了本地的加速器。

【参考文章】解决 Docker 下载 mcr.microsoft.com 镜像慢的办法


http://www.kler.cn/news/328237.html

相关文章:

  • ERROR [internal] load metadata for docker.io/library/openjdk:8
  • Spring Cloud Gateway接入WebSocket:实现实时通信
  • 详解代理模式-【静态代理与JDK动态代理】(非常的斯国一)
  • GO语言中make与new的区别
  • AI文本生成UI稿神器Galileo,程序员做独立开发必备
  • 【Linux-基础IO】如何理解Linux下一切皆文件磁盘的介绍
  • 链表的底层实现(Java版)(单向,双向,循环)
  • 2024年云南省职业院校技能大赛-云计算应用
  • ECMAScript标准
  • 【Android 14源码分析】Activity启动流程-1
  • 15分钟学 Python 第31天 :Web Scraping
  • java通过redis完成幂等性操作
  • Invalid row number (65536) outside allowable range (0..65535)
  • thinkphp6开发的通用网站系统源码
  • UI设计师面试整理-问题应对策略
  • Python从入门到高手4.1节-掌握条件控制语句
  • Rockchip RK3588 Android SDK编译方法
  • JWT(JSON Web Token)的介绍
  • 物理学基础精解【41】
  • 上位机图像处理和嵌入式模块部署(软硬结合才是嵌入式的精髓)
  • Elasticsearch基础_2.数据类型
  • python网站创建001:内容概览
  • 机器学习常用的评价指标原理和代码
  • 支持分页的环形队列
  • SqlSugar使用
  • JMeter 性能测试基本过程及示例
  • Spring Web MVC课后作业
  • [前端][easyui]easyui select 默认值
  • Java 编码系列:泛型详解与面试题解析
  • 探索Android折叠屏设备的分屏适配