{"id":4527,"date":"2024-05-23T16:50:23","date_gmt":"2024-05-23T08:50:23","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/index.php\/%e9%9d%a2%e8%af%95\/dockerfile-%e7%b2%be%e7%b2%b9%ef%bc%9a%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e7%b2%be%e9%80%9a%e9%95%9c%e5%83%8f%e6%9e%84%e5%bb%ba\/"},"modified":"2024-05-26T16:07:45","modified_gmt":"2024-05-26T08:07:45","slug":"dockerfile-%e7%b2%be%e7%b2%b9%ef%bc%9a%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e7%b2%be%e9%80%9a%e9%95%9c%e5%83%8f%e6%9e%84%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/%e9%9d%a2%e8%af%95\/dockerfile-%e7%b2%be%e7%b2%b9%ef%bc%9a%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e7%b2%be%e9%80%9a%e9%95%9c%e5%83%8f%e6%9e%84%e5%bb%ba\/","title":{"rendered":"Dockerfile \u7cbe\u7cb9\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a\u955c\u50cf\u6784\u5efa"},"content":{"rendered":"<div class=\"wxsyncmain\">\n<p><span style=\"font-size: 15px; letter-spacing: 0.034em;\">Do<\/span><span style=\"font-size: 15px; letter-spacing: 0.034em;\">ckerfile\u662f\u7528\u6765\u5feb\u901f\u521b\u5efa\u81ea\u5b9a\u4e49\u955c\u50cf\u7684\u4e00\u79cd\u6587\u672c\u683c\u5f0f\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5728\u6301\u7eed\u96c6\u6210\u548c\u6301\u7eed\u90e8\u7f72\u65f6\uff0c\u9700\u8981\u4f7f\u7528Dockerfile\u751f\u6210\u76f8\u5173\u5e94\u7528\u7a0b\u5e8f\u7684\u955c\u50cf<\/span><\/p>\n<p><span style=\"font-size: 15px;\"><strong>Dockerfile\u7684\u5e38\u7528\u547d\u4ee4<\/strong><\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"objectivec\"><code><span class=\"code-snippet_outer\">FROM\uff1a\u7ee7\u627f\u57fa\u7840\u955c\u50cf<\/span><\/code><code><span class=\"code-snippet_outer\">MAINTAINER\uff1a\u955c\u50cf\u5236\u4f5c\u4f5c\u8005\u7684\u4fe1\u606f\uff0c\u5df2\u5f03\u7528\uff0c\u4f7f\u7528LABEL\u66ff\u4ee3<\/span><\/code><code><span class=\"code-snippet_outer\">LABEL\uff1ak=v\u5f62\u5f0f\uff0c\u5c06\u4e00\u4e9b\u5143\u6570\u636e\u6dfb\u52a0\u81f3\u955c\u50cf<\/span><\/code><code><span class=\"code-snippet_outer\">RUN\uff1a\u7528\u6765\u6267\u884cshell\u547d\u4ee4<\/span><\/code><code><span class=\"code-snippet_outer\">EXPOSE\uff1a\u66b4\u9732\u7aef\u53e3\u53f7<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__built_in\">CMD<\/span>\uff1a\u542f\u52a8\u5bb9\u5668\u9ed8\u8ba4\u6267\u884c\u7684\u547d\u4ee4\uff0c\u4f1a\u88ab\u8986\u76d6<\/span><\/code><code><span class=\"code-snippet_outer\">ENTRYPOINT\uff1a\u542f\u52a8\u5bb9\u5668\u771f\u6b63\u6267\u884c\u7684\u547d\u4ee4\uff0c\u4e0d\u4f1a\u88ab\u8986\u76d6<\/span><\/code><code><span class=\"code-snippet_outer\">VOLUME\uff1a\u521b\u5efa\u6302\u8f7d\u70b9<\/span><\/code><code><span class=\"code-snippet_outer\">ENV\uff1a\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/span><\/code><code><span class=\"code-snippet_outer\">ADD\uff1a\u590d\u5236\u6587\u4ef6\u5230\u5bb9\u5668\uff0c\u4e00\u822c\u590d\u5236\u6587\u4ef6\uff0c\u538b\u7f29\u5305\u81ea\u52a8\u89e3\u538b<\/span><\/code><code><span class=\"code-snippet_outer\">COPY\uff1a\u590d\u5236\u6587\u4ef6\u5230\u5bb9\u5668\uff0c\u4e00\u822c\u590d\u5236\u76ee\u5f55<\/span><\/code><code><span class=\"code-snippet_outer\">WORKDIR\uff1a\u8bbe\u7f6e\u5bb9\u5668\u7684\u5de5\u4f5c\u76ee\u5f55<\/span><\/code><code><span class=\"code-snippet_outer\">USER\uff1a\u5bb9\u5668\u4f7f\u7528\u7684\u7528\u6237<\/span><\/code><code><span class=\"code-snippet_outer\">ARG\uff1a\u8bbe\u7f6e\u7f16\u8bd1\u955c\u50cf\u65f6\u4f20\u5165\u7684\u53c2\u6570<\/span><\/code><code><\/code><\/pre>\n<\/section>\n<p><span style=\"font-size: 15px;\"><strong>Dockerfile\u6837\u4f8b<\/strong><\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"bash\"><code><span class=\"code-snippet_outer\">FROM {image_name}:{image_tag}  <span class=\"code-snippet__comment\"># \u6307\u5b9a\u57fa\u7840\u955c\u50cf<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\"># MAINTAINER  {userinfo}  # \u7ef4\u62a4\u4eba\u4fe1\u606f<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">LABEL{key}{value}<span class=\"code-snippet__comment\">#\u6bd4\u5982\u8bbe\u7f6e\u4e3amaintainerauthor<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">USER {username}  <span class=\"code-snippet__comment\"># \u6307\u5b9a RUN\u3001CMD \u6216 ENTRYPOINT \u8fd0\u884c\u65f6\u4f7f\u7528\u7684\u7528\u6237<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">WORKDIR {workdir}  <span class=\"code-snippet__comment\"># \u4e3a\u540e\u7eed RUN\u3001CMD \u6216 ENTRYPOINT \u8fd0\u884c\u6307\u5b9a\u5de5\u4f5c\u76ee\u5f55<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">ENV {key} {value}  <span class=\"code-snippet__comment\"># \u4e3a\u540e\u7eed\u7684 RUN \u6307\u4ee4\u63d0\u4f9b\u4e00\u4e2a\u73af\u5883\u53d8\u91cf<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">RUN {bash <span class=\"code-snippet__built_in\">command<\/span>}  <span class=\"code-snippet__comment\"># \u8981\u6267\u884c\u7684\u547d\u4ee4\uff0cRUN \u4e00\u6b21\u955c\u50cf\u53e0\u52a0\u4e00\u6b21\uff08\u5927\u5c0f\uff09\uff0c\u591a\u4e2a\u547d\u4ee4\u53ef\u4ee5\u7528 &amp;&amp; \u8fde\u63a5\uff0c\u4ee5\u514d\u955c\u50cf\u592a\u5927<\/span><\/span><\/code><code><\/code><code><span class=\"code-snippet_outer\">ADD {local_file|dir} {container_dir}  <span class=\"code-snippet__comment\"># \u5c06\u672c\u5730\u6587\u4ef6\/\u76ee\u5f55\u62f7\u8d1d\u5230\u5bb9\u5668\u7684\u67d0\u4e2a\u76ee\u5f55\u91cc\uff0clocal_file|dir \u53ef\u4ee5\u662f\u672c\u5730\u6587\u4ef6\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a URL<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">COPY {local_file} {container_file}  <span class=\"code-snippet__comment\"># \u5c06\u672c\u5730\u6587\u4ef6\u62f7\u8d1d\u5230\u5bb9\u5668\uff0c\u4e0d\u652f\u6301 URL<\/span><\/span><\/code><code><\/code><code><span class=\"code-snippet_outer\">EXPOSE {ports}  <span class=\"code-snippet__comment\"># \u6307\u5b9a\u8981\u6620\u5c04\u7684\u7aef\u53e3\uff0c\u53ef\u4ee5\u5199\u591a\u4e2a\u3002\u9700\u914d\u5408 -P \u53c2\u6570\u4f7f\u7528\uff0c\u5373\u542f\u52a8\u5bb9\u5668\u65f6\u52a0\u4e0a -P \u53c2\u6570\uff0c\u5982\u679c\u60f3\u77e5\u9053\u4f60\u4e2a\u5177\u4f53\u7684\u6620\u5c04\u7aef\u53e3\uff0c\u53ef\u4ee5\u7528 -p \u6307\u5b9a<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">VOLUME [<span class=\"code-snippet__string\">\"{local_dir}\"<\/span>]  <span class=\"code-snippet__comment\"># \u521b\u5efa\u4e00\u4e2a\u53ef\u4ee5\u4ece\u672c\u673a\u6216\u5176\u4ed6\u5bb9\u5668\u6302\u8f7d\u7684\u6302\u8f7d\u70b9<\/span><\/span><\/code><code><\/code><code><span class=\"code-snippet_outer\">CMD [<span class=\"code-snippet__string\">\"command\"<\/span>, <span class=\"code-snippet__string\">\"param1\"<\/span>, <span class=\"code-snippet__string\">\"param2\"<\/span>]  <span class=\"code-snippet__comment\"># \u6307\u5b9a\u5bb9\u5668\u542f\u52a8\u65f6\u7528\u5230\u7684\u547d\u4ee4\uff0c\u53ea\u80fd\u6709\u4e00\u6761\uff01<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">ENTRYPOINT [<span class=\"code-snippet__string\">\"command\"<\/span>, <span class=\"code-snippet__string\">\"param1\"<\/span>, <span class=\"code-snippet__string\">\"param2\"<\/span>]  <span class=\"code-snippet__comment\"># \u6307\u5b9a\u5bb9\u5668\u542f\u52a8\u65f6\u7528\u5230\u7684\u547d\u4ee4\uff0c\u7c7b\u4f3c CMD\uff0c\u53ea\u80fd\u5199\u4e00\u6761\uff0c\u4e0d\u540c\u7684\u662f\uff1aCMD \u53ef\u4ee5\u88ab docker run \u6307\u4ee4\u8986\u76d6\uff0c\u800c ENTRYPOINT \u4e0d\u53ef\u4ee5\u88ab\u8986\u76d6<\/span><\/span><\/code><\/pre>\n<\/section>\n<p><span style=\"font-size: 15px;\"><strong>Dockerfile \u5b9e\u8df5<\/strong><\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"sql\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\"># vim dockerfile<\/span><\/span><\/code><code><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">## \u8bbe\u7f6e\u57fa\u7840\u955c\u50cf\u4e3aCentOS<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">FROM centos:7<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\"># \u8bbe\u7f6e\u4f5c\u8005<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">LABEL user yeweijie<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\"># \u5b89\u88c5\u5fc5\u8981\u5de5\u5177<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">RUN yum <span class=\"code-snippet__keyword\">install<\/span> -y pcre-devel wget net-tools gcc zlib zlib-devel make openssl-devel<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\"># \u5b89\u88c5Nginx<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__keyword\">ADD<\/span> <span class=\"code-snippet__keyword\">http<\/span>:\/\/nginx.org\/download\/nginx<span class=\"code-snippet__number\">-1.8<\/span><span class=\"code-snippet__number\">.0<\/span>.tar.gz .<\/span><\/code><code><span class=\"code-snippet_outer\">RUNtar-xfnginx<span class=\"code-snippet__number\">-1.8<\/span><span class=\"code-snippet__number\">.0<\/span>.tar.gz<\/span><\/code><code><span class=\"code-snippet_outer\">RUN mkdir -p \/usr\/<span class=\"code-snippet__keyword\">local<\/span>\/nginx<\/span><\/code><code><span class=\"code-snippet_outer\">RUN cd nginx<span class=\"code-snippet__number\">-1.8<\/span><span class=\"code-snippet__number\">.0<\/span> &amp;&amp; .\/configure <span class=\"code-snippet__comment\">--prefix=\/usr\/local\/nginx &amp;&amp; make &amp;&amp; make install<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">RUN rm -fv \/usr\/<span class=\"code-snippet__keyword\">local<\/span>\/nginx\/conf\/nginx.conf<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__keyword\">ADD<\/span> <span class=\"code-snippet__keyword\">http<\/span>:\/\/www.apelearn.com\/study_v2\/.nginx_conf \/usr\/<span class=\"code-snippet__keyword\">local<\/span>\/nginx\/conf\/nginx.conf<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\"># \u6620\u5c04\u7aef\u53e3<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">EXPOSE<span class=\"code-snippet__number\">80<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\"># \u8bbe\u7f6e\u6302\u8f7d\u70b9<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">VOLUME [<span class=\"code-snippet__string\">\"\/usr\/local\/nginx\/html\"<\/span>]<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\"># \u8bbe\u7f6e\u5bb9\u5668\u542f\u52a8\u65f6\u8981\u6267\u884c\u7684\u6307\u4ee4<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">ENTRYPOINT \/usr\/<span class=\"code-snippet__keyword\">local<\/span>\/nginx\/sbin\/nginx &amp;&amp; tail -f \/usr\/<span class=\"code-snippet__keyword\">local<\/span>\/nginx\/<span class=\"code-snippet__keyword\">logs<\/span>\/nginx_error.log<\/span><\/code><\/pre>\n<\/section>\n<p><span style=\"font-size: 15px;\"><strong>docker build\u547d\u4ee4\u6837\u4f8b<\/strong><\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"bash\"><code><span class=\"code-snippet_outer\">docker build -f \/path\/to\/Dockerfile -t {iamge_name}:{image_tag}  {workdir}  <\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">#-f\uff1a\u6307\u5b9a\u8981\u4f7f\u7528\u7684 Dockerfile \u6587\u4ef6\u8def\u5f84<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\"># -t \u8bbe\u7f6e\u955c\u50cftag<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\"># workdir\uff1a\u6307\u5b9a\u5f53\u524d\u547d\u4ee4\u8fd0\u884c\u7684\u5de5\u4f5c\u76ee\u5f55<\/span><\/span><\/code><code><\/code><\/pre>\n<\/section>\n<p><span style=\"font-size: 15px;\"><strong>\u6784\u5efa\u955c\u50cf<\/strong><\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"apache\"><code><span class=\"code-snippet_outer\">dockerbuild\u2013fdockerfile-tcentos7_nginx:test .<\/span><\/code><\/pre>\n<\/section>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"height: auto !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165333352.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-galleryid=\"\" data-imgfileid=\"100000344\" data-ratio=\"0.2351851851851852\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"height: auto !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165333352.png\" data-galleryid=\"\" data-imgfileid=\"100000344\" data-ratio=\"0.2351851851851852\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"height: auto !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165335955.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-galleryid=\"\" data-imgfileid=\"100000347\" data-ratio=\"0.3111111111111111\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"height: auto !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165335955.png\" data-galleryid=\"\" data-imgfileid=\"100000347\" data-ratio=\"0.3111111111111111\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/p>\n<p><span style=\"font-size: 15px;\"><strong>\u4f7f\u7528\u521a\u6253\u5305\u7684\u955c\u50cf\u8fd0\u884c\u4e00\u4e2adocker<\/strong><\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"css\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__selector-tag\">docker<\/span> <span class=\"code-snippet__selector-tag\">run<\/span> <span class=\"code-snippet__selector-tag\">-d<\/span> <span class=\"code-snippet__selector-tag\">--name<\/span>  <span class=\"code-snippet__selector-tag\">nginx_img<\/span> <span class=\"code-snippet__selector-tag\">-p<\/span> 36128<span class=\"code-snippet__selector-pseudo\">:80<\/span>  <span class=\"code-snippet__selector-tag\">centos7_nginx<\/span><span class=\"code-snippet__selector-pseudo\">:test<\/span> <span class=\"code-snippet__selector-tag\">bash<\/span><\/span><\/code><\/pre>\n<\/section>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"height: auto !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165338639.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-galleryid=\"\" data-imgfileid=\"100000348\" data-ratio=\"0.08148148148148149\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"height: auto !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165338639.png\" data-galleryid=\"\" data-imgfileid=\"100000348\" data-ratio=\"0.08148148148148149\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"height: auto !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165340700.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-galleryid=\"\" data-imgfileid=\"100000349\" data-ratio=\"0.287962962962963\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"height: auto !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165340700.png\" data-galleryid=\"\" data-imgfileid=\"100000349\" data-ratio=\"0.287962962962963\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/p>\n<p><span style=\"font-size: 15px;\"><strong>\u67e5\u770b\u955c\u50cf\u7ec6\u8282<\/strong><\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"bash\"><code><span class=\"code-snippet_outer\">docker inspect  centos7_nginx:test<\/span><\/code><\/pre>\n<\/section>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"height: auto !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165341326.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-galleryid=\"\" data-imgfileid=\"100000350\" data-ratio=\"0.7509259259259259\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"height: auto !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165341326.png\" data-galleryid=\"\" data-imgfileid=\"100000350\" data-ratio=\"0.7509259259259259\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/p>\n<p style=\"text-align: center;\">\n<h1><span style=\"font-size: 15px;\"><strong>Docker Build Cache \u7f13\u5b58\u6e05\u7406<\/strong><\/span><\/h1>\n<p><span style=\"color: #4d4d4d; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; font-variant-ligatures: no-common-ligatures; letter-spacing: normal; text-align: start; text-wrap: wrap; background-color: #ffffff;\">Docker 18.09 \u5f15\u5165\u4e86 BuildKit \uff0c\u63d0\u5347\u4e86\u6784\u5efa\u8fc7\u7a0b\u7684\u6027\u80fd\u3001\u5b89\u5168\u3001\u5b58\u50a8\u7ba1\u7406\u7b49\u80fd\u529b\u3002<\/span><\/p>\n<p><span style=\"color: #4d4d4d; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; font-variant-ligatures: no-common-ligatures; letter-spacing: normal; text-align: start; text-wrap: wrap; background-color: #ffffff;\"><code style=\"outline: 0px; font-family: 'Source Code Pro', 'DejaVu Sans Mono', 'Ubuntu Mono', 'Anonymous Pro', 'Droid Sans Mono', Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, 'PingFang SC', 'Microsoft YaHei', sans-serif; font-size: 14px; line-height: 22px; color: #c7254e; background-color: #f9f2f4; border-radius: 2px; padding: 2px 4px; font-synthesis-style: auto; font-variant-ligatures: no-common-ligatures; letter-spacing: normal; text-align: start; text-wrap: wrap;\">docker system df<\/code><span style=\"color: #4d4d4d; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-variant-ligatures: no-common-ligatures; letter-spacing: normal; text-align: start; text-wrap: wrap; background-color: #ffffff;\">\u547d\u4ee4\uff0c\u7c7b\u4f3c\u4e8e Linux\u4e0a\u7684 df \u547d\u4ee4\uff0c\u7528\u4e8e\u67e5\u770b Docker \u7684\u78c1\u76d8\u4f7f\u7528\u60c5\u51b5\uff1a<\/span><\/span><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"height: auto !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165347849.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-galleryid=\"\" data-imgfileid=\"100000351\" data-ratio=\"0.25203252032520324\" data-s=\"300,640\" data-type=\"png\" data-w=\"861\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"height: auto !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165347849.png\" data-galleryid=\"\" data-imgfileid=\"100000351\" data-ratio=\"0.25203252032520324\" data-s=\"300,640\" data-type=\"png\" data-w=\"861\" \/><\/noscript><\/p>\n<p><strong><span style=\"font-size: 15px;\">Images <\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u6240\u6709\u955c\u50cf\u5360\u7528\u7684\u7a7a\u95f4\uff0c\u5305\u62ec\u62c9\u53d6\u4e0b\u6765\u7684\u955c\u50cf\uff0c\u548c\u672c\u5730\u6784\u5efa\u7684\u3002<\/span><\/p>\n<p><strong><span style=\"font-size: 15px;\">Containers<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u8fd0\u884c\u7684\u5bb9\u5668\u5360\u7528\u7684\u7a7a\u95f4\uff0c\u8868\u793a\u6bcf\u4e2a\u5bb9\u5668\u7684\u8bfb\u5199\u5c42\u7684\u7a7a\u95f4\u3002<\/span><\/p>\n<p><strong><span style=\"font-size: 15px;\">Local Volumes<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u5bb9\u5668\u6302\u8f7d\u672c\u5730\u6570\u636e\u5377\u7684\u7a7a\u95f4\u3002<\/span><\/p>\n<p><strong><span style=\"font-size: 15px;\">Build Cache<\/span><\/strong><span style=\"font-size: 15px;\"> \uff1a\u955c\u50cf\u6784\u5efa\u8fc7\u7a0b\u4e2d\u4ea7\u751f\u7684\u7f13\u5b58\u7a7a\u95f4\uff08\u53ea\u6709\u5728\u4f7f\u7528 BuildKit \u65f6\u624d\u6709\uff0cDocker 18.09 \u4ee5\u540e\u53ef\u7528\uff09\u3002<\/span><\/p>\n<p><span style=\"font-size: 15px;\">\u6700\u540e <strong>RECLAIMABLE <\/strong>\u8fd9\u5217\u8868\u793a\u53ef\u56de\u6536\u7684\u5927\u5c0f\u3002<\/span><\/p>\n<p><span style=\"color: #4d4d4d; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; font-variant-ligatures: no-common-ligatures; letter-spacing: normal; text-align: start; text-wrap: wrap; background-color: #ffffff;\">\u4e00\u952e\u6e05\u7406 Build Cache \u7f13\u5b58\u547d\u4ee4\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<pre class=\"code-snippet__js\" data-lang=\"nginx\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__attribute\">docker<\/span> builder prune<\/span><\/code><\/pre>\n<\/section>\n<p>\u5982\u679c\u4f60\u60f3\u8981\u91cd\u65b0\u6784\u5efa\u955c\u50cf\uff0c\u9700\u8981\u7528\u4e0a\u9762\u7684\u547d\u4ee4\u505a\u6e05\u7406\u955c\u50cf\u7f13\u5b58\u3002<\/p>\n<p style=\"display: none;\">\n<blockquote><p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7: \u5c0f\u53f6\u6765\u6ef4\u8336<\/p><\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>Dockerfile\u662f\u7528\u6765\u5feb\u901f\u521b\u5efa\u81ea\u5b9a\u4e49\u955c\u50cf\u7684\u4e00\u79cd\u6587\u672c\u683c\u5f0f\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5728\u6301\u7eed\u96c6\u6210\u548c\u6301\u7eed\u90e8\u7f72\u65f6\uff0c\u9700\u8981\u4f7f\u7528Dockerfile\u751f\u6210\u76f8\u5173 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":4518,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[30],"tags":[],"class_list":["post-4527","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-30"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165329848-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165333352.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165329848-300x127.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165329848-1024x434.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165333352.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165329848-300x127.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165329848-1024x434.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165329848.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165333352.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165333352.png","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165335955.png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165335955.png","id":"image3"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165338639.png","id":"image4"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165338639.png","id":"image5"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165340700.png","id":"image6"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165340700.png","id":"image7"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165341326.png","id":"image8"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165341326.png","id":"image9"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165347849.png","id":"image10"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524165347849.png","id":"image11"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"\u9762\u8bd5","post_date":"2024-05-23","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":321,"next_post_id":4716,"next_post_title":"\u5982\u4f55\u62e5\u6709\u4e00\u4e2a\u4f18\u96c5\u7684 Controller\uff1f","previous_post_id":4467,"previous_post_title":"\u4e0d\u662f\uff0c\u4f60\u8fd8\u5728\u968f\u4fbf\u8bbe\u8ba1\u6570\u636e\u5e93\u5b57\u6bb5\u7c7b\u578b\u548c\u957f\u5ea6\uff1f","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/4527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=4527"}],"version-history":[{"count":1,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/4527\/revisions"}],"predecessor-version":[{"id":4717,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/4527\/revisions\/4717"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/4518"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=4527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=4527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=4527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}