黄色网址大全免费-黄色网址你懂得-黄色网址你懂的-黄色网址有那些-免费超爽视频-免费大片黄国产在线观看

專注Java教育14年 全國咨詢/投訴熱線:400-8080-105
動力節點LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁 hot資訊 Docker加速鏡像

Docker加速鏡像

更新時間:2021-12-24 10:53:51 來源:動力節點 瀏覽1892次

前言

由于眾所周知的原因,在國內拉取國外的docker鏡像時,速度會很慢,甚至失敗。比如拉取dotnet core的鏡像。

比如以下兩個鏡像,拉取的時候非常慢

mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim
mcr.microsoft.com/dotnet/core/sdk:3.1-buster

既然是網絡原因,那么就可以通過以下兩種方式解決

1.國內鏡像倉庫

2.從國外鏡像倉庫下載鏡像上傳到國內鏡像倉庫

配置國內鏡像倉庫

倉庫列表

可自行搜索關鍵字docker國內鏡像源尋找

配置方法

在CentOS中可以通過修改daemon配置文件/etc/docker/daemon.json來配置

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["鏡像倉庫"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

從國外鏡像倉庫下載鏡像上傳到國內鏡像倉庫

前提

有一臺訪問主流鏡像倉庫速度快的境外服務器,安裝好docker

開通阿里云的容器鏡像倉庫服務

步驟

1.使用docker pull命令下載鏡像

[root@104 ~]# docker pull mcr.microsoft.com/dotnet/core/sdk:3.1-buster
3.1-buster: Pulling from dotnet/core/sdk
d6ff36c9ec48: Pull complete 
c958d65b3090: Pull complete 
edaf0a6b092f: Pull complete 
80931cf68816: Pull complete 
7b9b87089c2a: Pull complete 
4f2c2524f197: Pull complete 
b7b0f8dc0c5c: Pull complete 
Digest: sha256:1aa53e4fa32dbba836e64e7863955b6b2b165f3a4f8f8aeed648a249300fae07
Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/sdk:3.1-buster
mcr.microsoft.com/dotnet/core/sdk:3.1-buster

2.查看鏡像信息,并且tag到阿里云鏡像倉庫

[root@104 ~]# docker images
REPOSITORY                          TAG                 IMAGE ID            CREATED             SIZE
mcr.microsoft.com/dotnet/core/sdk   3.1-buster          9ab567a29502        2 weeks ago         708MB
[root@104 ~]# docker tag 9ab567a29502 registry.cn-shenzhen.aliyuncs.com/dotnetcore-vincent/sdk:3.1-buster

如上命令,使用tag命令把鏡像關聯到鏡像倉庫,用到的參數是image id和倉庫地址,然后push

[root@104 ~]# docker push registry.cn-shenzhen.aliyuncs.com/dotnetcore-vincent/sdk:3.1-buster
The push refers to repository [registry.cn-shenzhen.aliyuncs.com/dotnetcore-vincent/sdk]
f506d7422ef0: Layer already exists 
5188b84c74d0: Layer already exists 
896ff95e1760: Layer already exists 
e5df62d9b33a: Layer already exists 
7a9460d53218: Layer already exists 
b2765ac0333a: Layer already exists 
0ced13fcf944: Layer already exists 
3.1-buster: digest: sha256:1aa53e4fa32dbba836e64e7863955b6b2b165f3a4f8f8aeed648a249300fae07 size: 1800

因為我的鏡像倉庫里已經有了這個鏡像,所以不會再次上傳

使用

把鏡像上傳好之后,就可以在Dockerfile中使用了,速度超快,如下面的Dockerfile

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM registry.cn-shenzhen.aliyuncs.com/dotnetcore-vincent/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM registry.cn-shenzhen.aliyuncs.com/dotnetcore-vincent/sdk:3.1-buster AS build
WORKDIR /src
COPY ["DockerDemo/DockerDemo.csproj", "DockerDemo/"]
RUN dotnet restore "DockerDemo/DockerDemo.csproj"
COPY . .
WORKDIR "/src/DockerDemo"
RUN dotnet build "DockerDemo.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "DockerDemo.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "DockerDemo.dll"]

最后

給出兩個dotnet core相關的鏡像地址

registry.cn-shenzhen.aliyuncs.com/dotnetcore-vincent/sdk:3.1-buster
registry.cn-shenzhen.aliyuncs.com/dotnetcore-vincent/aspnet:3.1-buster-slim
registry.cn-shenzhen.aliyuncs.com/rabbitmq-vincent/rabbitmq:3.8.8
registry.cn-shenzhen.aliyuncs.com/dotnet-vincent/sdk:5.0 
registry.cn-shenzhen.aliyuncs.com/dotnet-vincent/aspnet:5.0

以上就是關于“Docker加速鏡像”的介紹,大家如果想了解更多相關知識,不妨來關注一下動力節點的Docker菜鳥教程,里面的內容豐富,由淺到深,適合沒有基礎的朋友學習,相信對大家會有所幫助的。

提交申請后,顧問老師會電話與您溝通安排學習

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 亚洲免费网站在线观看 | 美女一级毛片无遮挡内谢 | 免费人成网站 | 高清日韩 | 在线观看免费播放网址成人 | 国产精品一区高清在线观看 | 日韩人体在线 | 在线国产一区 | 久久精品人人爽人人爽 | 最近更新中文字幕第一页 | 亚洲国产经典 | 亚洲国产成人久久午夜 | 中文字幕 制服诱惑 | 久久久久久久久网站 | 爆操波多野结衣 | 最新欧美一级视频 | 特级全黄一级毛片免费 | 久久精品中文字幕第一页 | 成人啪精品视频免费网站 | 播播成人网 | 免费看黄的网页 | 国产成人精品免费2021 | 久久午夜影视 | 国产裸舞在线一区二区 | 久久福利影院 | 亚洲黄色免费观看 | 亚洲九九精品 | 国产精品欧美亚洲韩国日本99 | 亚洲专区在线播放 | 亚洲欧美日韩高清一区二区三区 | 亚洲狠狠97婷婷综合久久久久 | 国产成人永久在线播放 | 欧美les视频xxxx在线观看 | 午夜精品亚洲 | 欧美a级v片在线观看一区 | 国产国语一级a毛片高清视频 | 精品久久久久久中文字幕一区 | 一级毛片人与动免费观看 | 成年网在线观看免费观看网址 | 国产黄色免费观看 | 日韩激情视频在线 |