docker~aspnetcore2.0镜像安装软件的加速器

简介:

一般对于安装软件加速时,我们大多数会选择阿里云,而对于aspnetcore2.0这个进项来说,由于使用的是Debian操作系统,所有我们要找到它对应的mirror列表,下面是我整理的一个sources.list加速列表,我们把它放在和Dockerfile相同的位置,在Dockerfile生成镜像时把它复制到里面去,替换之前的apt-update地址源即可。

source.list内容

deb http://mirrors.aliyun.com/debian wheezy main contrib non-free
deb-src http://mirrors.aliyun.com/debian wheezy main contrib non-free
deb http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free
deb http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free

然后我们对Dockerfile进行一些修改,在生成镜像时把它复制到镜像里

FROM microsoft/aspnetcore:2.0
ARG source
COPY sources.list /etc/apt/sources.list
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
RUN apt-get update && apt-get -y install libgdiplus
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "SMS.dll"]

然后我们再去生成镜像,就会非常非常快了!

当然,你也可以不添加这个文件,而直接把文本覆盖到原来的source.list文件里

FROM microsoft/aspnetcore:2.0
ARG source

RUN echo "deb http://mirrors.aliyun.com/debian wheezy main contrib non-free \
deb-src http://mirrors.aliyun.com/debian wheezy main contrib non-free \
deb http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free \
deb-src http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free \
deb http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free \
deb-src http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free" > /etc/apt/sources.list

RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
RUN apt-get update &&  apt-get install libgdiplus -y
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Pilipa.SMS.dll"]

上面的做法也是完全没有问题的!

你要是在阿里云服务器上,那就是内网对内网,更快!

本文转自博客园张占岭(仓储大叔)的博客,原文链接:docker~aspnetcore2.0镜像安装软件的加速器,如需转载请自行联系原博主。

目录
相关文章
|
5月前
|
Docker 容器 Perl
云效flow构建docker镜像更换apt源为阿里镜像源
在 Dockerfile 中添加命令以更换 Debian 源为阿里云镜像,加速容器内软件包下载。核心命令通过 `sed` 实现源地址替换,并更新 apt 软件源。其中 `cat` 命令用于验证替换是否成功,实际使用中可删除该行。
1061 32
|
4月前
|
缓存 Shell 网络安全
将应用程序打包成Docker镜像时可能遇到哪些问题?
将应用程序打包成Docker镜像时可能遇到哪些问题?
393 77
|
4月前
|
Shell 应用服务中间件 nginx
docker 镜像的部分常用命令
docker镜像常用命令
144 16
|
4月前
|
关系型数据库 MySQL Docker
|
5月前
|
Ubuntu Linux 网络安全
Ubuntu Docker镜像:支持systemctl、SSH、VNC
总的来说,创建一个支持systemctl、SSH和VNC的Ubuntu Docker镜像需要一些技术知识,但是通过学习和实践,我们可以掌握这些技术。这将使我们能够更有效地使用Docker,更好地管理我们的应用程序和服务。CentOS系统中的日志文件位置和管理
167 17
|
5月前
|
Ubuntu 安全 网络安全
Docker镜像:Ubuntu支持systemctl、SSH和VNC
总的来说,Docker提供了一个灵活且强大的方式来创建和运行自定义的Ubuntu镜像。通过理解和使用Dockerfile,你可以轻松地创建一个支持systemctl、SSH和VNC的Ubuntu镜像。
334 21
|
5月前
|
NoSQL Redis 数据库
Docker平台上的Redis镜像运行
这就是如何在Docker平台上运行Redis镜像的全部过程。走进Docker和Redis的世界,探索更多可能!
360 10
|
6月前
|
安全 API 算法框架/工具
大模型文件Docker镜像化部署技术详解
大模型文件Docker镜像化部署技术详解
810 2