{"id":63817,"date":"2025-04-29T09:07:55","date_gmt":"2025-04-29T01:07:55","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63817\/"},"modified":"2025-04-29T09:07:55","modified_gmt":"2025-04-29T01:07:55","slug":"docker%e6%80%8e%e4%b9%88%e5%af%bc%e5%85%a5%e9%95%9c%e5%83%8f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63817\/","title":{"rendered":"docker\u600e\u4e48\u5bfc\u5165\u955c\u50cf"},"content":{"rendered":"<blockquote><p>\n  docker \u4e2d\u5bfc\u5165\u955c\u50cf\u6d89\u53ca\u4ece\u8fdc\u7a0b\u4ed3\u5e93\u83b7\u53d6\u9884\u6784\u5efa\u7684\u5bb9\u5668\u6620\u50cf\uff0c\u5e76\u5c06\u5176\u5bfc\u5165\u672c\u5730\u4ed3\u5e93\u3002\u6b65\u9aa4\u5305\u62ec\uff1a\u62c9\u53d6\u955c\u50cf\uff08docker pull\uff09\u5217\u51fa\u5df2\u62c9\u53d6\u955c\u50cf\uff08docker images\uff09\u5bfc\u5165\u955c\u50cf\u5230\u672c\u5730\u4ed3\u5e93\uff08docker import\uff09\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/05\/2024060509361996143.jpg\" class=\"aligncenter\" title=\"docker\u600e\u4e48\u5bfc\u5165\u955c\u50cf\u63d2\u56fe\" alt=\"docker\u600e\u4e48\u5bfc\u5165\u955c\u50cf\u63d2\u56fe\" \/><\/p>\n<p><strong>Docker \u5bfc\u5165\u955c\u50cf<\/strong><\/p>\n<p>\u5728 Docker \u4e2d\u5bfc\u5165\u955c\u50cf\u662f\u83b7\u53d6\u548c\u4f7f\u7528\u9884\u6784\u5efa\u5bb9\u5668\u6620\u50cf\u7684\u8fc7\u7a0b\u3002\u955c\u50cf\u672c\u8d28\u4e0a\u662f\u5305\u542b\u5e94\u7528\u7a0b\u5e8f\u53ca\u5176\u4f9d\u8d56\u9879\u7684\u53ef\u79fb\u690d\u8f6f\u4ef6\u5305\u3002\u5bfc\u5165\u955c\u50cf\u540e\uff0c\u4f60\u53ef\u4ee5\u57fa\u4e8e\u5b83\u4eec\u521b\u5efa\u548c\u8fd0\u884c\u5bb9\u5668\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u62c9\u53d6\u955c\u50cf\uff1a<\/strong><\/p>\n<pre>docker pull &lt;\u955c\u50cf\u540d\u79f0&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u62c9\u53d6 Ubuntu \u955c\u50cf\uff0c\u8bf7\u8fd0\u884c\uff1a<\/p>\n<pre>docker pull ubuntu<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u5217\u51fa\u5df2\u62c9\u53d6\u955c\u50cf\uff1a<\/strong><\/p>\n<pre>docker images<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u663e\u793a\u6240\u6709\u5df2\u62c9\u53d6\u7684\u955c\u50cf\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u5bfc\u5165\u955c\u50cf\u5230\uff1a<\/strong><\/p>\n<pre>docker import &lt;tar \u6587\u4ef6\u8def\u5f84&gt; &lt;\u955c\u50cf\u540d\u79f0[:\u6807\u7b7e]&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u5bfc\u5165\u672c\u5730 tar \u6587\u4ef6\u4e2d\u7684\u955c\u50cf\u5230\u540d\u4e3a &#8220;my-image&#8221; \u7684\u955c\u50cf\u4e2d\uff0c\u8bf7\u8fd0\u884c\uff1a<\/p>\n<pre>docker import my-image.tar my-image:latest<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li> <strong>\u9a8c\u8bc1\u5bfc\u5165\uff1a<\/strong><br \/>\u518d\u6b21\u8fd0\u884c &#8221; images&#8221; \u547d\u4ee4\u4ee5\u9a8c\u8bc1\u5bfc\u5165\u662f\u5426\u6210\u529f\u3002\u5bfc\u5165\u7684\u955c\u50cf\u5e94\u663e\u793a\u5728\u5217\u8868\u4e2d\u3002<\/li>\n<\/ol>\n<p><strong>\u5176\u4ed6\u65b9\u6cd5\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>\u4f7f\u7528 Dockerfile \u52a0\u8f7d\u955c\u50cf\uff1a<\/strong><br \/>Dockerfile \u4e2d\u5305\u542b\u4e00\u4e2a &#8220;FROM&#8221; \u6307\u4ee4\uff0c\u7528\u4e8e\u6307\u5b9a\u57fa\u7840\u955c\u50cf\u3002\u6784\u5efa Dockerfile \u65f6\uff0c\u5b83\u4f1a\u81ea\u52a8\u62c9\u53d6\u548c\u5bfc\u5165\u57fa\u7840\u955c\u50cf\u3002<\/li>\n<li> <strong>\u4f7f\u7528 Docker Compose \u52a0\u8f7d\u955c\u50cf\uff1a<\/strong><br \/>Docker Compose \u662f\u4e00\u79cd\u7528\u4e8e\u5b9a\u4e49\u548c\u7ba1\u7406 Docker \u5e94\u7528\u7a0b\u5e8f\u7684\u5de5\u5177\u3002\u5b83\u652f\u6301\u4f7f\u7528 &#8220;image&#8221; \u5b57\u6bb5\u6307\u5b9a\u8981\u5bfc\u5165\u7684\u955c\u50cf\u3002<\/li>\n<\/ul>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u62c9\u53d6\u955c\u50cf\u9700\u8981\u7f51\u7edc\u8fde\u63a5\u3002<\/li>\n<li>\u955c\u50cf\u540d\u79f0\u53ef\u4ee5\u5305\u542b\u540d\u79f0\u7a7a\u95f4\uff08\u4f8b\u5982\uff0c&#8221;library\/ubuntu&#8221;\uff09\uff0c\u4ee5\u6307\u5b9a\u6765\u81ea Docker Hub \u7b49\u6ce8\u518c\u8868\u7684\u955c\u50cf\u3002<\/li>\n<li>\u6807\u7b7e\u6307\u5b9a\u955c\u50cf\u7684\u7279\u5b9a\u7248\u672c\u3002\u7559\u7a7a\u8868\u793a\u6700\u65b0\u7248\u672c\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5bfc\u5165\u955c\u50cf\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>docker \u4e2d\u5bfc\u5165\u955c\u50cf\u6d89\u53ca\u4ece\u8fdc\u7a0b\u4ed3\u5e93\u83b7\u53d6\u9884\u6784\u5efa\u7684\u5bb9\u5668\u6620\u50cf\uff0c\u5e76\u5c06\u5176\u5bfc\u5165\u672c\u5730\u4ed3\u5e93\u3002\u6b65\u9aa4\u5305\u62ec\uff1a\u62c9\u53d6\u955c\u50cf\uff08docker pull\uff09\u5217\u51fa\u5df2\u62c9\u53d6\u955c\u50cf\uff08docker images\uff09\u5bfc\u5165\u955c\u50cf\u5230\u672c\u5730\u4ed3\u5e93\uff08docker import\uff09 Docker \u5bfc\u5165\u955c\u50cf \u5728 Docker \u4e2d\u5bfc\u5165\u955c\u50cf\u662f\u83b7\u53d6\u548c\u4f7f\u7528\u9884\u6784\u5efa\u5bb9\u5668\u6620\u50cf\u7684\u8fc7\u7a0b\u3002\u955c\u50cf\u672c\u8d28\u4e0a\u662f\u5305\u542b\u5e94\u7528\u7a0b\u5e8f\u53ca\u5176\u4f9d\u8d56\u9879\u7684\u53ef\u79fb\u690d\u8f6f\u4ef6\u5305\u3002\u5bfc\u5165\u955c\u50cf\u540e\uff0c\u4f60\u53ef\u4ee5\u57fa\u4e8e\u5b83\u4eec\u521b\u5efa\u548c\u8fd0\u884c\u5bb9\u5668\u3002 \u6b65\u9aa4\uff1a \u62c9\u53d6\u955c\u50cf\uff1a docker pull &lt;\u955c\u50cf\u540d\u79f0&gt; \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u8981\u62c9\u53d6 Ubuntu \u955c\u50cf\uff0c\u8bf7\u8fd0\u884c\uff1a docker pull ubuntu \u767b\u5f55\u540e\u590d\u5236 \u5217\u51fa\u5df2\u62c9\u53d6\u955c\u50cf\uff1a docker images \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u663e\u793a\u6240\u6709\u5df2\u62c9\u53d6\u7684\u955c\u50cf\u3002 \u5bfc\u5165\u955c\u50cf\u5230\uff1a docker import &lt;tar \u6587\u4ef6\u8def\u5f84&gt; &lt;\u955c\u50cf\u540d\u79f0[:\u6807\u7b7e]&gt; \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u8981\u5bfc\u5165\u672c\u5730 tar \u6587\u4ef6\u4e2d\u7684\u955c\u50cf\u5230\u540d\u4e3a &#8220;my-image&#8221; \u7684\u955c\u50cf\u4e2d\uff0c\u8bf7\u8fd0\u884c\uff1a docker import my-image.tar my-image:latest \u767b\u5f55\u540e\u590d\u5236 \u9a8c\u8bc1\u5bfc\u5165\uff1a\u518d\u6b21\u8fd0\u884c &#8221; images&#8221; \u547d\u4ee4\u4ee5\u9a8c\u8bc1\u5bfc\u5165\u662f\u5426\u6210\u529f\u3002\u5bfc\u5165\u7684\u955c\u50cf\u5e94\u663e\u793a\u5728\u5217\u8868\u4e2d\u3002 \u5176\u4ed6\u65b9\u6cd5\uff1a \u4f7f\u7528 Dockerfile \u52a0\u8f7d\u955c\u50cf\uff1aDockerfile \u4e2d\u5305\u542b\u4e00\u4e2a &#8220;FROM&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63817","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=63817"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63817\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}