基于Debain11构建asp。netcore6。x的基础运
dotnet跨平台Linux环境说明
此处我们基于Debian11的Linux发行版,实现目标是编写Dockerfile构建asp。netcore6。x框架的runtime基础镜像。
在Docker容器化运行环境中,应用程序运行中存在异常情况,此时可以借助一些常用的基础工具方便排查,因此我们需要在asp。netcore6。xruntime基础镜像添加linux环境常用的基础工具。
注意:基础镜像的构建需要考虑镜像的体积和打包工具的安全隐患,此处不做过多讨论。Debian简介
1、Debian是一个社区
来自世界各地的数以千计的志愿者共同为Debian操作系统工作,注重自由和开源软件。认识Debian计划。
2、Debian是一个操作系统
Debian是一个自由的操作系统,由Debian计划开发和维护。Debian是一个自由的Linux发行版,添加了数以千计的应用程序以满足用户的需要。
关于Debian更多信息,请查看https:www。debian。orgintroindex。zhcn。htmlDebian发行版本
Debian一直维护着至少三个发行版本:稳定版(stable),测试版(testing)和不稳定版(unstable)。
1、稳定版(stable稳定版包含了Debian官方最近一次发行的软件包。作为Debian的正式发行版本,它是我们优先推荐给用户您选用的版本。当前Debian的稳定版版本号是11,开发代号为bullseye。最初版本为11。0,于2021年08月14日发布,其更新11。6已于2022年12月17日发布。
2、测试版(testing)测试版包含了那些暂时未被收录进入稳定版的软件包,但它们已经进入了候选队列。使用这个版本的最大益处在于它拥有更多版本较新的软件。想要了解什么是测试版以及如何成为稳定版的更多信息,请看DebianFAQ。当前的测试版版本代号是bookworm。
3、不稳定版(unstable)不稳定版存放了Debian现行的开发工作。通常,只有开发者和那些喜欢过惊险刺激生活的人选用该版本。推荐使用不稳定版的用户订阅debiandevelannounce邮件列表,以接收关于重大变更的通知,比如有可能导致问题的升级。不稳定版的版本代号永远都被称为sid。
4、发行生命周期
Debian通常会按照一定的规律每隔一段时间发布一个新稳定版。对每个稳定发行版本,用户可以得到三年的完整支持以及额外两年的长期支持。
请查看DebianReleases维基页面和DebianLTS维基页面以了解详细信息。
更多详细信息,请查看https:www。debian。orgreleases关于Debian11
Debian11带有Linux5。10内核,这是一个长期支持(LTS)版本。一个新的内核显然意味着对硬件有更好的支持,特别是较新的硬件以及性能的改进。
debian11
这里我们使用Debian11,代号为bullseye,网络安装,用于64位PC(amd64)debian11。6。0amd64netinst。iso。
关于Debian11更多信息:新发布的Debian11BullseyeLinux发行版的7大亮点https:linux。cnarticle136951。htmlLinux常用基础工具
当在Linux服务器执行telnet命令时,如果提示commandnotfound:telnet,说明服务器上并未安装telnet命令,需要安装此命令。
下面介绍在linux服务器如何安装telnet、curl、ifconfig、vim、ping等工具。
首先,介绍一个安装工具时必须的命令aptinstall。aptinstall是应用程序管理器,用于一键安装软件包,与源码安装不同的是,该指令会自动检测并安装依赖,而且用apt安装的包都是成熟的软件包,基本不存在安装包有严重bug或者文件缺失的情况。spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;1、首先执行如下命令,更新相关资源。将所有包的来源更新,也就是提取最新的包信息,这一命令使用率非常高。span
aptupdate
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;2、安装telnetspan
aptinstalltelnet
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;3、安装curlspan
aptinstallcurl
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;4、安装ifconfigspan
aptinstallnettools
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;5、安装vimspan
aptinstallvim
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;6、安装pingspan
aptinstallinetutilsping
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;7、安装ipaddrspan
aptinstalliproute2
上面这些基础工具的安装,可以整合一条命令,执行操作如下:aptupdateaptinstallynettoolsiproute2iputilspingtelnetcurlvim
执行上面命令,如果不是root用户,需在前面添加sudo提权,继续执行操作。Dockerfile中RUN指令
上面我们介绍了linux环境中常用的基础工具,此处我们app应用程序是容器化运行环境,为了方便排查异常信息,通常会在runtime基础镜像中添加一些常用工具。
在编写Dickerfile构建asp。netcoreruntime镜像环境时,我们先来了解下Dockerfile中的RUN指令。RUN语法格式
在Dockerfile中RUN指令的编写格式有两种:
【shell形式】,命令在shell中运行,默认情况下,Linux是binshc、Windows是cmdSC;
【exec形式】,按照JSONArray格式解析,意味着必须使用双引号【】包含参数,而不能使用单引号【’】;RUN语义说明
RUN指令在当前镜像的顶层上新建层执行命令,同时提交执行结果。提交的结果会在接下来的Dockerfile处理。
分层RUN指令和生成提交符合Docker的核心理念,即:提交便利,容器可以依据任意历史镜像构建,像源代码管理一样。exec形式能够避免shell形式表达含义模糊的问题,同时能够在一个不包含shell命令的基础镜像上执行RUN指令。shell形式的默认shell可以通过SHELL修改。shell形式中,若是指令参数过长,可以使用符号【】换行显示。spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;RUN参数不换行。span
RUNbinbashcspanstylecolor:98c379;lineheight:26px;sourceHOME。bashrc;echoHOMEspan
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;RUN参数换行。span
RUNbinbashcspanstylecolor:98c379;lineheight:26px;sourceHOME。bashrc;
echoHOMEspan
exec形式是按照JSONArray格式解析,必须使用双引号【】包含参数。
与shell形式不同,exec形式不会调用shell命令行,意味着不会进行shell处理。例如:运行RUN〔spanstylecolor:98c379;lineheight:26px;echospan,spanstylecolor:98c379;lineheight:26px;spanstylecolor:d19a66;lineheight:26px;HOMEspanspan〕不会对spanstylecolor:d19a66;lineheight:26px;HOMEspan进行变量替换。
如果需要shell处理,那么可以使用shell形式或直接执行shell;
例如:RUN〔spanstylecolor:98c379;lineheight:26px;shspan,spanstylecolor:98c379;lineheight:26px;cspan,spanstylecolor:98c379;lineheight:26px;echospanstylecolor:d19a66;lineheight:26px;HOMEspanspan〕。
当使用spanstylecolor:e6c07b;lineheight:26px;execspan形式直接执行shell时,与shell形式类似,应用的shell是宿主机而非Docker。
exec形式中的JSON,必须转译反斜杠【】。Windows系统中,反斜杠【】是路径分隔符,是需要特别关注的。否则,由于不是有效的JSON,执行时会出现异常从而失败。spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;错误写法span
RUN〔spanstylecolor:98c379;lineheight:26px;c:windowssystem32asklist。exespan〕
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;正确写法span
RUN〔spanstylecolor:98c379;lineheight:26px;c:windowssystem32tasklist。exespan〕
RUN指令的缓存不会在下次构建时自动失效。RUNaptdistupgradey指令的缓存将在下次构建时重用。
RUN指令的缓存可以通过使用nocache标志置为无效,例如:dockerbuildnocache
RUN指令的缓存可由ADD和COPY指令置为无效。编写Dockerfile构建Runtime基础镜像
在Docker中,编写Dockerfile是有个细节需要注意,RUN指令执行多个命令时,可以合并写成一个,在Dockerfile中每执行一个指令都会对应的生成一个层,相应的构建镜像的体积也会随之增加。ASP。NETCoreRuntime基础镜像微软MCR容器镜像仓库,ASP。NETCoreRuntime
ASP。NETCoreRuntime
访问地址:https:mcr。microsoft。comenusproductdotnetaspnetaboutDockerfile编写
上面我们介绍了RUN指令的语法格式,同样的这里我们为了尽量建设镜像构建的层,通常情况我们会把多个命令整合为一个RUN指令执行,完整Dockerfile编写如下:FROMmcr。microsoft。comdotnetaspnet:6。0
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;Debian源添加参考span
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;https:developer。aliyun。commirrordebian?spma2c6h。13651102。0。0。3e221b1137LtM1span
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;https:mirrors。ustc。edu。cnhelpdebian。htmlspan
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;https:mirrors。tuna。tsinghua。edu。cnhelpdebianspan
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;RUN使用shell语法span
RUNsediEspanstylecolor:98c379;lineheight:26px;s(debsecurity)。debian。orgmirrors。aliyun。comgspanetcaptsources。list
RUNsedispanstylecolor:98c379;lineheight:26px;ssnapshot。debian。orgmirrors。ustc。edu。cngspanetcaptsources。list
RUNsedispanstylecolor:98c379;lineheight:26px;sdeb。debian。orgmirrors。ustc。edu。cngspanetcaptsources。list
RUNaptupdateaptinstallynettoolsiproute2iputilspingtelnetcurlvim
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;RUN使用exec语法span
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;RUN〔apt,update〕span
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;RUN〔apt,install,y,vim,curl,telnet,iputilsping,iproute2,nettools〕span
Windows环境使用WSL2安装DockerDesktop工具
注意:在windows环境使用Dockerfile构建镜像,需要安装DockerDesktop工具并启动运行。
Windows环境安装DockerDesktop工具,推荐使用WSL2模式运行。此处不过多讲解安装细节,请自行查看资料镜像安装。
dockerdesktop
DockerEngine添加如下信息:{
spanstylecolor:98c379;lineheight:26px;builderspan:{
spanstylecolor:98c379;lineheight:26px;gcspan:{
spanstylecolor:98c379;lineheight:26px;defaultKeepStoragespan:spanstylecolor:98c379;lineheight:26px;20GBspan,
spanstylecolor:98c379;lineheight:26px;enabledspan:spanstylecolor:56b6c2;lineheight:26px;truespan
}
},
spanstylecolor:98c379;lineheight:26px;dnsspan:〔
spanstylecolor:98c379;lineheight:26px;8。8。8。8span,
spanstylecolor:98c379;lineheight:26px;8。8。4。4span
〕,
spanstylecolor:98c379;lineheight:26px;experimentalspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:98c379;lineheight:26px;featuresspan:{
spanstylecolor:98c379;lineheight:26px;buildkitspan:spanstylecolor:56b6c2;lineheight:26px;truespan
},
spanstylecolor:98c379;lineheight:26px;insecureregistriesspan:〔
spanstylecolor:98c379;lineheight:26px;https:hub。atguigu。comspan
〕,
spanstylecolor:98c379;lineheight:26px;registrymirrorsspan:〔
spanstylecolor:98c379;lineheight:26px;https:registry。dockercn。comspan,
spanstylecolor:98c379;lineheight:26px;http:hubmirror。c。163。comspan,
spanstylecolor:98c379;lineheight:26px;https:mirror。ccs。tencentyun。comspan,
spanstylecolor:98c379;lineheight:26px;https:docker。mirrors。ustc。edu。cnspan,
spanstylecolor:98c379;lineheight:26px;https:cr。console。aliyun。comspan
〕
}
dockerbuild构建image镜像执行dockerbuild构建命令:dockerbuildtaspnet:6。0debian11amd64。
输出如下image镜像构建步骤信息:〔〕Building0。6s(99)FINISHED
〔internal〕loadbuilddefinitionfromDockerfile0。0s
transferringdockerfile:32B0。0s
〔internal〕load。dockerignore0。0s
transferringcontext:2B0。0s
〔internal〕loadmetadataspanstylecolor:c678dd;lineheight:26px;forspanmcr。microsoft。comdotnetaspnet:6。00。4s
〔15〕FROMmcr。microsoft。comdotnetaspnet:6。0sha256:a4ac0ac8b96842c3d4161339e641d335e44f52647bdeb4ed619ac830。0s
CACHED〔25〕RUNsediEspanstylecolor:98c379;lineheight:26px;s(debsecurity)。debian。orgmirrors。aliyun。comgspanetcaptsources。list0。0s
CACHED〔35〕RUNsedispanstylecolor:98c379;lineheight:26px;ssnapshot。debian。orgmirrors。ustc。edu。cngspanetcaptsources。list0。0s
CACHED〔45〕RUNsedispanstylecolor:98c379;lineheight:26px;sdeb。debian。orgmirrors。ustc。edu。cngspanetcaptsources。list0。0s
CACHED〔55〕RUNaptupdateaptinstallynettoolsiproute2iputilspingtelnetcurlvim0。0s
exportingtoimage0。0s
exportinglayers0。0s
writingimagesha256:8e4e01b9340eef513279899468870ff57826a1e4f3a6f0b3689212d88f3119eb0。0s
namingtodocker。iolibraryaspnet:6。0debian11amd640。0s
Usespanstylecolor:98c379;lineheight:26px;dockerscanspantorunSnyktestsagainstimagestofindvulnerabilitiesandlearnhowtofixthem
从上面输出的信息可以看出,Dockerfile文件中每一行单独编写的命令,都会当做一个步骤执行,一共执行〔55〕个步骤。查看docker镜像信息
此时我打开DockerDesktop桌面端工具,选择Images,搜索框输入tag名称【aspnetdebian11amd64:6。0】就可以看到刚才构建的镜像,体积270。54MB。
dockerimages
和原生【mcr。microsoft。comdotnetaspnet:6。0】镜像相比,体积增加170。51MB,新增的这部分体积,主要是我们在这个镜像的基础上,添加了一些linux环境的常用小工具(nettools、iproute2、iputilsping、telnet、curl、vim)。
我们可以点击【aspnetdebian11amd64:6。0】镜像,即可进入镜像查看构建的层信息,如下所示:
image详细信息
查看上面的镜像层信息,同样的我们也可以使用命令操作查看,操作如下:
dockerinspect:获取容器镜像的元数据。dockerinspect〔OPTIONS〕NAMEID〔NAMEID。。。〕
OPTIONS说明:f:指定返回值的模板文件。s:显示总的文件大小。type:为指定类型返回JSON。
具体命令如下:dockerinspectaspnet:6。0debian11amd64
输出如下信息:〔
{
spanstylecolor:d19a66;lineheight:26px;Idspan:spanstylecolor:98c379;lineheight:26px;sha256:8e4e01b9340eef513279899468870ff57826a1e4f3a6f0b3689212d88f3119ebspan,
spanstylecolor:d19a66;lineheight:26px;RepoTagsspan:〔
spanstylecolor:98c379;lineheight:26px;aspnet:6。0debian11amd64span
〕,
spanstylecolor:d19a66;lineheight:26px;RepoDigestsspan:〔〕,
spanstylecolor:d19a66;lineheight:26px;Parentspan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Commentspan:spanstylecolor:98c379;lineheight:26px;buildkit。dockerfile。v0span,
spanstylecolor:d19a66;lineheight:26px;Createdspan:spanstylecolor:98c379;lineheight:26px;20230219T07:44:04。106566658Zspan,
spanstylecolor:d19a66;lineheight:26px;Containerspan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;ContainerConfigspan:{
spanstylecolor:d19a66;lineheight:26px;Hostnamespan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Domainnamespan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Userspan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;AttachStdinspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;AttachStdoutspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;AttachStderrspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;Ttyspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;OpenStdinspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;StdinOncespan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;Envspan:spanstylecolor:56b6c2;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Cmdspan:spanstylecolor:56b6c2;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Imagespan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Volumesspan:spanstylecolor:56b6c2;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;WorkingDirspan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Entrypointspan:spanstylecolor:56b6c2;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;OnBuildspan:spanstylecolor:56b6c2;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Labelsspan:spanstylecolor:56b6c2;lineheight:26px;span
},
spanstylecolor:d19a66;lineheight:26px;DockerVersionspan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Authorspan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Configspan:{
spanstylecolor:d19a66;lineheight:26px;Hostnamespan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Domainnamespan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Userspan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;AttachStdinspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;AttachStdoutspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;AttachStderrspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;Ttyspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;OpenStdinspan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;StdinOncespan:spanstylecolor:56b6c2;lineheight:26px;falsespan,
spanstylecolor:d19a66;lineheight:26px;Envspan:〔
spanstylecolor:98c379;lineheight:26px;PATHusrlocalsbin:usrlocalbin:usrsbin:usrbin:sbin:binspan,
spanstylecolor:98c379;lineheight:26px;ASPNETCOREURLShttp::80span,
spanstylecolor:98c379;lineheight:26px;DOTNETRUNNINGINCONTAINERtruespan,
spanstylecolor:98c379;lineheight:26px;DOTNETVERSION6。0。14span,
spanstylecolor:98c379;lineheight:26px;ASPNETVERSION6。0。14span
〕,
spanstylecolor:d19a66;lineheight:26px;Cmdspan:〔
spanstylecolor:98c379;lineheight:26px;bashspan
〕,
spanstylecolor:d19a66;lineheight:26px;Imagespan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Volumesspan:spanstylecolor:56b6c2;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;WorkingDirspan:spanstylecolor:98c379;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Entrypointspan:spanstylecolor:56b6c2;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;OnBuildspan:spanstylecolor:56b6c2;lineheight:26px;span,
spanstylecolor:d19a66;lineheight:26px;Labelsspan:spanstylecolor:56b6c2;lineheight:26px;span
},
spanstylecolor:d19a66;lineheight:26px;Architecturespan:spanstylecolor:98c379;lineheight:26px;amd64span,
spanstylecolor:d19a66;lineheight:26px;Osspan:spanstylecolor:98c379;lineheight:26px;linuxspan,
spanstylecolor:d19a66;lineheight:26px;Sizespan:spanstylecolor:d19a66;lineheight:26px;270542384span,
spanstylecolor:d19a66;lineheight:26px;VirtualSizespan:spanstylecolor:d19a66;lineheight:26px;270542384span,
spanstylecolor:d19a66;lineheight:26px;GraphDriverspan:{
spanstylecolor:d19a66;lineheight:26px;Dataspan:{
spanstylecolor:d19a66;lineheight:26px;LowerDirspan:spanstylecolor:98c379;lineheight:26px;varlibdockeroverlay2z1zc2q5ucw0srd1q6fz9dv5zsdiff:varlibdockeroverlay24vf1uowirpwps4nw4guvfr610diff:varlibdockeroverlay2xzob6lo9w8ita21r9o6qdowh3diff:varlibdockeroverlay21a04b4cea9f8ea832c5f91a20d4ddd4f29f6ec5acb8ebbda6848282ec8159590diff:varlibdockeroverlay25036b7ee8c50e873affdb40f9d1fd0e37573631587ed6b1f45347a10995ad935diff:varlibdockeroverlay2f7d1f588113cb3de37d0cd574614db511a098ba64e18f02ade45cb4b1d431fb6diff:varlibdockeroverlay2f0c4b961c76c425d8383575ca78c176a890d78d871a5cf60daab2ddc96ffee8ddiff:varlibdockeroverlay2f7c839b494ad006d157084d919c15e812e10e57a8ac1c5cdda4d0150bf494f21diffspan,
spanstylecolor:d19a66;lineheight:26px;MergedDirspan:spanstylecolor:98c379;lineheight:26px;varlibdockeroverlay29zxjyc54rcaf107f6cj6fhiaxmergedspan,
spanstylecolor:d19a66;lineheight:26px;UpperDirspan:spanstylecolor:98c379;lineheight:26px;varlibdockeroverlay29zxjyc54rcaf107f6cj6fhiaxdiffspan,
spanstylecolor:d19a66;lineheight:26px;WorkDirspan:spanstylecolor:98c379;lineheight:26px;varlibdockeroverlay29zxjyc54rcaf107f6cj6fhiaxworkspan
},
spanstylecolor:d19a66;lineheight:26px;Namespan:spanstylecolor:98c379;lineheight:26px;overlay2span
},
spanstylecolor:d19a66;lineheight:26px;RootFSspan:{
spanstylecolor:d19a66;lineheight:26px;Typespan:spanstylecolor:98c379;lineheight:26px;layersspan,
spanstylecolor:d19a66;lineheight:26px;Layersspan:〔
spanstylecolor:98c379;lineheight:26px;sha256:4695cdfb426a05673a100e69d2fe9810d9ab2b3dd88ead97c6a3627246d83815span,
spanstylecolor:98c379;lineheight:26px;sha256:f30d150c01520fbbbdd1bedcef3f940d809c82a46e08301dcc713903d7272ba3span,
spanstylecolor:98c379;lineheight:26px;sha256:fe674e2b138caf1ef6a67419d5fb0a9081ca0759d97ce711be80d5d4d67145e1span,
spanstylecolor:98c379;lineheight:26px;sha256:ff13768cb51ea8fe1831d93c2d18690c3fdca8cfee40b75a738f62b133413573span,
spanstylecolor:98c379;lineheight:26px;sha256:355b7bb8c23e0d867141b0af69ecb6df39730bcd1b6c754cfae9ad36ca3f5572span,
spanstylecolor:98c379;lineheight:26px;sha256:8d56eaae8bfea0a5eac4caf4350fa1987c162cd7dba828aa292cc15c3e90d91bspan,
spanstylecolor:98c379;lineheight:26px;sha256:b7d0c701d1f04294b2b98d3103c3856c9cbabc592cde48d3e07eb03bff7cb18aspan,
spanstylecolor:98c379;lineheight:26px;sha256:46ef367d7575beda39ffd3774b4d47b29c2fe0b628f1269b4626053ca44169d5span,
spanstylecolor:98c379;lineheight:26px;sha256:6809bcac556f83ca4489ba09980a5bef05c9bc7463a45e4dac7fb600beec1c4espan
〕
},
spanstylecolor:d19a66;lineheight:26px;Metadataspan:{
spanstylecolor:d19a66;lineheight:26px;LastTagTimespan:spanstylecolor:98c379;lineheight:26px;20230219T08:46:50。196739744Zspan
}
}
〕
镜像构建后,此时如果有镜像仓库(腾讯云平台准备Docker私有镜像仓库或者IDC机房搭建),确保vm和宿主机之间通信可以正常登录访问,此处以腾讯云Docker私有镜像仓库为例:spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;登录腾讯云dockerregistryspan
sudodockerloginusername〔user〕ccr。ccs。tencentyun。com
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;提示输入对应的密码即可span
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;从registry拉取镜像span
sudodockerpullccr。ccs。tencentyun。comdotnetimagename:〔tag〕
spanstylecolor:5c6370;fontstyle:italic;lineheight:26px;将镜像推送到registryspan
sudodockerloginusername〔user〕ccr。ccs。tencentyun。com
sudodockertag〔ImageIdimagename:tag〕ccr。ccs。tencentyun。comdotnetaspnet:6。0debian11amd64
sudodockerpushccr。ccs。tencentyun。comdotnetaspnet:6。0debian11amd64
到这里我们就演示完Dockerfile的编写,以及image镜像构建的全过程。总结
掌握Dockerfile文件语法格式的编写,熟悉RUN指令中多个命令的编写方式(减少image镜像构建层,相应的减少镜像体积大小),顺便熟悉下Docker镜像的构建dockerbuild和镜像的push(推送)和pull(拉取)基本操作,感兴趣的小伙伴可以跟随上面描述动手实践起来,可以加深对Docker镜像构建的理解。
3月24日周五新闻联播要闻18条3月24日周五新闻联播要闻18条财联社3月24日电,今天新闻联播主要内容有1谱写和平发展新篇章习近平主席提出构建人类命运共同体理念十周年2李强主持召开国务院常务会议3赵乐际在广东调
本周演出只要旋律响起,总会想到那一段特别的过往爱乐之城电影主题音乐会爱乐之城唯美浪漫经典电影名曲视听音乐会这是一场电影与音乐会的碰撞精选十几部豆瓣高分好评电影数首被传承歌唱的经典电影配乐音乐与光影,都被岁月赋予了力量不知不觉中与银幕上的故事产生共鸣
焦点访谈丨春风拂暖就业路就业是民生之本。习近平总书记指出,强化就业优先政策,健全就业促进机制,促进高质量充分就业。今年1月至3月,人力资源和社会保障部等11部门在全国联合开展2023年春风行动暨就业援助月
郁金香绽放!来盐城大丰荷兰花海赴一场春日之约视频加载中现代快报讯(通讯员马秀云记者王菲)樱花梅花桃花春天来临,百花齐放。最近,盐城大丰荷兰花海的郁金香也盛开了,成为众多游客的浪漫打卡地。从蓓蕾初露到花开绽放,郁金香透露着别样
80后河南女子远嫁南非土豪,生一娃,住富人区别墅雇两个黑人保姆阅读前先点关注,以便您讨论和分享,感谢您的参与和支持,欧阳比心这是地球人物纪讲述的第229位人物。2019年1月1号,一位80后的河南女子为爱远嫁南非,生下一个混血儿子,如今住在南
乒坛爆出大冷门!张本智和逆转世界第5夺冠,当众脱衣庆祝太嚣张大家好,今天和球迷们聊一聊国乒的最新消息,聊一聊乒坛的最新消息。备受球迷关注的wtt冠军赛即将在河南新乡举行,很多球迷也非常的开心,能够在家门口欣赏到顶级的乒乓球赛事,大家也是欢欣
东南亚嘎的不止是腰子,还有智商首先,这篇文章没有任何偏袒的意思,起因是最近打开头条或者是抖音,到处都是在说东南亚诈骗,不能去,噶腰子。真有那么可怕吗?为什么人人都认可这种说法?我疫情前做旅游,经常来往马来西亚,
泰国男模餐厅全网爆火?又一个缅甸中转站?最近泰国男模餐厅突然在网上爆火,吸引中国女性去打卡。据说这家餐厅在偏僻的地方,出行涨价不算,关键有生命安全问题!泰国在去年成为亚洲第一个大麻合法化国家。现在大街小巷没少开跟大麻相关
泰国之旅割腰子风波背后的真相揭秘尊敬的读者们,您是否曾经梦想过度假时游览泰国这个迷人的国度,享受令人陶醉的美食古老的寺庙独特的文化以及美丽的海滩?然而,在这片热带天堂的背后,一个令人不安的现象正在悄然蔓延。这就是
痛心!一地2人遭雷击身亡!一图看懂如何不被雷到今天(3月24日),一则消息让网友痛心3月22日,受对流云团影响,浙江温州多地出现强对流天气,两人遭雷击不幸遇难。据报道,一名遇难者为海上作业人员,另一名女子在下班步行回家途中被击
德力西电气321电工节,助力追光的人成为光电气从业者是在黑暗中追光的人,是守护万家灯火的精锐,是发挥专业技能的尖兵。作为城市用电安全的守护者,他她们用自己的双手,通过可靠的产品和优质的服务,为社会提供安全稳定的电力设施,为