{"id":50572,"date":"2023-04-21T14:04:49","date_gmt":"2022-11-03T11:16:35","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/"},"modified":"2024-04-30T00:33:41","modified_gmt":"2024-04-29T16:33:41","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528Docker\u6765\u7ba1\u7406\u6570\u636e"},"content":{"rendered":"<p>\u203b \u8fd9\u662f\u5173\u4e8e\u4f7f\u7528Docker\u8fdb\u884c\u5f00\u53d1\u7684\u6587\u7ae0\u7684\u7eed\u7bc7\u3002<\/p>\n<h1>Immutability\u548c\u6570\u636e<\/h1>\n<p>\u6211\u5728\u4e0a\u8ff0\u6587\u7ae0\u4e2d\u63d0\u5230\u4e86\u8fdb\u884c\u5468\u8fb9\u7cfb\u7edf\u7684\u6a21\u62df\u96c6\u6210\u6d4b\u8bd5\u7684\u8bdd\u9898\u3002<\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u662f\u5c06\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u6240\u4f9d\u8d56\u7684\u5468\u8fb9\u670d\u52a1\u548c\u4e2d\u95f4\u4ef6\u8fdb\u884c\u6a21\u62df\u5316\u548c\u5bb9\u5668\u5316\uff0c\u5e76\u5728\u5f00\u53d1\u9636\u6bb5\u8fdb\u884c\u4eff\u771f\u6574\u5408\u6d4b\u8bd5\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/4-0.png\" alt=\"\u5468\u8fba.png\" \/><\/div>\n<p>\u5c06\u5bb9\u5668\u5316\u610f\u5473\u7740\u53d8\u5f97\u4e0d\u53ef\u53d8\uff0c\u5e76\u4e14\u8fd9\u4e5f\u610f\u5473\u7740\u6bcf\u6b21\u542f\u52a8\u65f6\u90fd\u662f\u7a7a\u767d\u7684\u3002<\/p>\n<p>\u5c06\u5e94\u7528\u7a0b\u5e8f\u8bbe\u4e3a\u65e0\u72b6\u6001\u5177\u6709\u8bb8\u591a\u4f18\u70b9\uff0c\u4f46\u8fd9\u4e5f\u610f\u5473\u7740\u7cfb\u7edf\u4e2d\u67d0\u5904\u5b58\u5728\u7740\u7edf\u4e00\u7ba1\u7406\u72b6\u6001\u7684\u8282\u70b9\uff0c\u901a\u5e38\u7531\u6570\u636e\u5e93\u627f\u62c5\u6b64\u8d23\u4efb\u3002<\/p>\n<p>\u90a3\u4e48\uff0c\u6211\u4eec\u662f\u5426\u53ef\u4ee5\u5c06\u6570\u636e\u5e93\u53d8\u4e3a\u4e0d\u53ef\u53d8\u72b6\u6001\u540c\u65f6\u4fdd\u6301\u6709\u72b6\u6001\u5462\uff1f<\/p>\n<h1>Docker \u4e4b\u5916\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/h1>\n<p>\u5728Docker\u4e4b\u524d\uff0c\u6709\u4e9b\u4eba\u8ba4\u4e3a\u53ea\u9700\u8981\u4f7f\u7528Docker\u6765\u7ba1\u7406\u5e94\u7528\u7a0b\u5e8f\uff0c\u800c\u5b58\u50a8\u53ef\u4ee5\u91c7\u7528\u5176\u4ed6\u65b9\u6cd5\uff0c\u8fd9\u4e2a\u60f3\u6cd5\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/10-0.png\" alt=\"\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9.png\" \/><\/div>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u793e\u5185\u30a4\u30f3\u30c8\u30e9<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">RDS, Cloud SQL \u7b49\u30af\u30e9\u30a6\u30c9\u30b5\u30fc\u30d3\u30b9<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30db\u30b9\u30c8\u30de\u30b7\u30f3\u4e0a<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">VirtualBox , Hyper-V \u306e\u4e0a<\/ul>\n<p>\u25a0 \u5171\u540c\u7684\u6570\u636e\u5e93<\/p>\n<p>\u5bf9\u4e8e\u793e\u5185Intranet\u6216\u4e91\u670d\u52a1\u6765\u8bf4\uff0c\u56e2\u961f\u4f1a\u5171\u4eab\u4e00\u4e2a\u6570\u636e\u5e93\u6765\u8fdb\u884c\u8bbf\u95ee\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Pros<\/ul>\n<\/li>\n<\/ul>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7ba1\u7406\u8005\u304c\u7ba1\u7406\u3057\u3066\u304f\u308c\u308b<br \/>\n\u5168\u54e1\u306e\u74b0\u5883\u304c\u63c3\u3046<br \/>\n\u672c\u756a\u74b0\u5883\u304c RDS \u3060\u3063\u305f\u308a\u3001\u7528\u610f\u3055\u308c\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b5\u30fc\u30d0\u306a\u3089\u3001\u958b\u767a\u74b0\u5883\u3068\u306e\u5dee\u7570\u304c\u5c0f\u3055\u3044<\/p>\n<p>Cons<\/p>\n<p>\u8ab0\u304b\u306e\u5909\u66f4\u304c\u4ed6\u306e\u8ab0\u304b\u306b\u5f71\u97ff<br \/>\n\u606f\u304c\u9577\u304f\u306a\u308a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u4ed5\u69d8\u306b\u306a\u308b\u3068\u5927\u5909<\/p>\n<p>Infrastructure as Code \u304c\u3067\u304d\u3066\u3044\u308c\u3070\u554f\u984c\u306a\u3044<\/p>\n<p>\u25a0 \u4e2a\u4eba\u6570\u636e\u5e93<\/p>\n<p>\u5982\u679c\u5728\u4e3b\u673a\u4e0a\u6216\u5728\u4e3b\u673a\u4e0a\u521b\u5efa\u7684\u865a\u62df\u673a\u4e0a\u653e\u7f6e\u6570\u636e\u5e93\uff0c\u5c31\u53ef\u4ee5\u4e3a\u81ea\u5df1\u51c6\u5907\u4e00\u4e2a\u6570\u636e\u5e93\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Pros<\/ul>\n<\/li>\n<\/ul>\n<p>\u5404\u958b\u767a\u8005\u304c\u72ec\u7acb\u3057\u3066\u4f5c\u696d\u304c\u3067\u304d\u308b<\/p>\n<p>\u30c6\u30b9\u30c8\u7528\u306b\u3001\u3061\u3087\u3063\u3068\u30c7\u30fc\u30bf\u3044\u3058\u3063\u305f\u308a<br \/>\n\u5834\u5408\u306b\u3088\u3063\u3066\u306f\u3001\u30b9\u30ad\u30fc\u30de\u3092\u3044\u3058\u3063\u305f\u308a<\/p>\n<p>\u30b9\u30ad\u30fc\u30de\u5909\u66f4\u306e\u63d0\u6848\u524d\u306b\u5f71\u97ff\u7bc4\u56f2\u304c\u5206\u304b\u308b<\/p>\n<p>Cons<\/p>\n<p>\u81ea\u5206\u3067\u7ba1\u7406\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044<br \/>\n\u5168\u54e1\u306e\u74b0\u5883\u304c\u63c3\u308f\u306a\u3044<\/p>\n<p>\u79c1\u306f\u3067\u304d\u308b\u306e\u306b\u3001\u3042\u306a\u305f\u306f\u3067\u304d\u306a\u3044<\/p>\n<p>\u606f\u304c\u9577\u304f\u306a\u308b\u3068\u3001\u7d50\u5c40\u5927\u5909<\/p>\n<p>Infrastructure as Code \u304c\u3067\u304d\u3066\u3044\u308c\u3070\u554f\u984c\u306a\u3044<\/p>\n<p>\u90a3\u4e48\u5728\u8fd9\u91cc\uff0c\u901a\u8fc7Docker\u5316\uff0c\u4f60\u671f\u671b\u5f97\u5230\u4ec0\u4e48\uff1f<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/19-0.png\" alt=\"\u30c7\u30fc\u30bf\u30d9\u30fc\u30b94.png\" \/><\/div>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7ba1\u7406\u8005\u304c\u7ba1\u7406\u3057\u3066\u304f\u308c\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>\u30a4\u30e1\u30fc\u30b8\u3092\u8ab0\u304b\u304c\u4f5c\u308c\u3070\u3001\u5f8c\u306f\u305d\u308c\u3092\u4f7f\u3046\u3060\u3051<br \/>\n\u5efa\u3066\u308b\u306e\u3082\u4e00\u77ac<\/p>\n<p>\u5404\u958b\u767a\u8005\u304c\u72ec\u7acb\u3057\u3066\u4f5c\u696d\u304c\u3067\u304d\u308b<\/p>\n<p>\u5f53\u7136<\/p>\n<p>\u74b0\u5883\u304c\u63c3\u3046<\/p>\n<p>\u5168\u54e1\u304c\u540c\u3058\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u3048\u3070\u5b9f\u73fe\u3067\u304d\u308b<\/p>\n<p>\u672c\u756a\u3068\u306e\u5dee\u7570<\/p>\n<p>\u672c\u756a\u3082 Docker \u3067\u884c\u3051\u308c\u3070 \u5dee\u7570\u306f\u306a\u3044<\/p>\n<p>\u672c\u5f53\u306b ?<\/p>\n<p>\u606f\u304c\u9577\u304f\u306a\u308b\u3068\u3001\u7d50\u5c40\u5927\u5909<\/p>\n<p>Immutable \u306a\u4f7f\u3044\u65b9\u3092\u3059\u308c\u3070\u3001\u6bce\u5ea6\u7834\u68c4 \/ \u751f\u6210\u3055\u308c\u308b\u306e\u3067\u3001Infrastructure as Code \u304c\u5fb9\u5e95\u3055\u308c\u308b<\/p>\n<p>\u56e0\u6b64\uff0c\u6211\u4eec\u5c06\u770b\u770bDocker\u5982\u4f55\u89e3\u51b3\u4ee5\u4e0b\u95ee\u9898\u3002<\/p>\n<h1>\u4f5c\u4e3aDocker\u7684\u89e3\u51b3\u65b9\u6848<\/h1>\n<h2>\u6570\u636e\u5e93\u76f8\u5173\u7684\u5b98\u65b9\u5bb9\u5668<\/h2>\n<p>\u9996\u5148\uff0c\u5e94\u8be5\u5982\u4f55\u521b\u5efa\u6570\u636e\u5e93\u5bb9\u5668\u6620\u50cf\u3002<\/p>\n<p>PostgreSQL\u548cMySQL\u7b49\u4e3b\u8981\u7684\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff0c\u4ee5\u53caMongoDB\u548cRedis\u7b49\u6240\u8c13\u7684NoSQL\u6570\u636e\u5e93\uff0c\u51e0\u4e4e\u90fd\u6709\u5b98\u65b9\u7684Docker\u955c\u50cf\u53ef\u7528\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">RDB<\/ul>\n<\/li>\n<\/ul>\n<p>PostgreSQL<br \/>\nMySQL<br \/>\nMariaDB<\/p>\n<p>NoSQL<\/p>\n<p>Redis<br \/>\nmemcached<br \/>\nMongoDB<br \/>\nCassandra<\/p>\n<p>\u8fd9\u4e9b\u90fd\u662f\u57fa\u672c\u7684\u201c\u7a7a\u6570\u636e\u201d\u6982\u5ff5\u3002\u5982\u679c\u6ca1\u6709\u7279\u6b8a\u7406\u7531\uff0c\u6211\u4eec\u901a\u5e38\u4f1a\u4ee5\u5b98\u65b9\u5f62\u8c61\u4e3a\u57fa\u7840\u4f7f\u7528\u3002<\/p>\n<p>\u7136\u800c\uff0c\u5982\u679c\u9700\u8981\u8c03\u6574\uff0c\u5219\u53ef\u4ee5\u5728Dockerfile\u4e2d\u4ece\u5934\u6784\u5efa\u3002<\/p>\n<h2>\u6570\u636e\u5e93\u8bbe\u8ba1\u4e0e\u6784\u5efa<\/h2>\n<p>\u56e0\u6b64\uff0c\u6211\u4eec\u5f00\u59cb\u8fdb\u884c\u6570\u636e\u5e93\u7684\u8bbe\u8ba1\u548c\u6784\u5efa\u3002<\/p>\n<p>\u8bbe\u8ba1\u8005\u8d1f\u8d23\u8bbe\u8ba1\u6570\u636e\u5e93\u3001\u7528\u6237\u3001\u8868\u7b49\u3002<\/p>\n<p>\u5728\u8fd9\u91cc\uff0c\u5982\u679c\u8fc7\u4e8e\u8f7b\u6613\u5730\u5728Dockerfile\u4e2d\u8fde\u7eed\u5199\u5165psql -c ~ \uff08\u5047\u8bbe\u4e3aPostgreSQL\uff09\uff0c\u6216\u8fde\u63a5\u5230\u5df2\u542f\u52a8\u7684\u6570\u636e\u5e93\u5bb9\u5668\u5e76\u6267\u884ccreate database ~\uff0c\u5c06\u4f1a\u9020\u6210\u9ebb\u70e6\u3002<\/p>\n<p>Docker \u4e0d\u4f1a\u8f7b\u6613\u4fdd\u7559\u72b6\u6001\u3002<\/p>\n<h2>\u5728Docker\u4e2d\u5b9e\u73b0\u6570\u636e\u6301\u4e45\u5316<\/h2>\n<p>Docker\u8981\u6c42\u57fa\u672c\u4e0a\u662f\u4e0d\u53ef\u66f4\u6539\u7684\u3002<br \/>\n\u540c\u65f6\uff0c\u5b83\u4e0d\u559c\u6b22\u955c\u50cf\u4e2d\u5305\u542b\u6570\u636e\uff08\u72b6\u6001\uff09\u7684\u505a\u6cd5\u3002<\/p>\n<p>\u8003\u8651\u4ee5\u4e0b\uff0c\u4ee5PostgreSQL\u4f5c\u4e3a\u524d\u63d0\u3002<\/p>\n<h3>1. \u5305\u542b\u6570\u636e\u7684\u56fe\u50cf\u5316\u72b6\u6001<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/38-0.png\" alt=\"\u30c7\u30fc\u30bf\u30d9\u30fc\u30b97.png\" \/><\/div>\n<p>\u5236\u4f5c\u4e00\u4e2a\u5305\u62ec\u6240\u6709\u6a21\u5f0f\u6570\u636e\u7684\u521d\u59cb\u56fe\u50cf\uff0c\u8fd9\u662f\u6bcf\u4e2a\u4eba\u9996\u5148\u8003\u8651\u7684\u4e8b\u60c5\u3002<\/p>\n<h4>&#8220;\u4f18\u70b9&#8221;<\/h4>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u304c\u53ef\u80fd<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Immutability \u3082\u5b8c\u74a7<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">Docker Registry \u306b\u767b\u9332\u3059\u308c\u3070\u3001\u767b\u9332 \/ \u914d\u5e03 \u306e\u30a8\u30b3\u30b7\u30b9\u30c6\u30e0\u306b\u4e57\u308c\u308b<\/ul>\n<h4>\u25c6 \u7f3a\u70b9<\/h4>\n<ul class=\"post-ul\">Docker \u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u304c\u63a8\u5968\u3057\u3066\u3044\u306a\u3044 ? (\u5f8c\u8ff0)<\/ul>\n<h4>\u5b9e\u65bd\u65b9\u6848<\/h4>\n<p>\u4f5c\u4e3a\u5927\u81f4\u7684\u5b9e\u73b0\u65b9\u6cd5\uff0c\u6709\u4ee5\u4e0b\u51e0\u79cd\u60f3\u6cd5\u3002<\/p>\n<p>A. \u5728 Dockerfile \u4e2d\u8fdb\u884c\u8bb0\u5f55\uff0c\u901a\u8fc7 docker build \u5c06\u5176\u6253\u5305\u6210\u955c\u50cf\u3002<\/p>\n<p>B. \u5728\u542f\u52a8\u7684\u5bb9\u5668\u4e2d\u8fdb\u884c\u66f4\u6539\uff0c\u901a\u8fc7 docker commit \/ save \/ export \u5c06\u5176\u6253\u5305\u6210\u955c\u50cf\u3002<br \/>\n&#8211; docker run ~<br \/>\n&#8211; docker exec psql -c &#8220;~~&#8221;<br \/>\n&#8211; docker commit or save or export ~<\/p>\n<p>\u6211\u60f3\u8981\u9009\u62e9\u57fa\u7840\u8bbe\u65bd\u5373\u4ee3\u7801\u65b9\u6848A\uff0c\u4f46\u6211\u4eec\u9700\u8981\u770b\u4e00\u4e0b\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6848\u3002<\/p>\n<h4>1. \u901a\u8fc7 Dockerfile \u6dfb\u52a0\u7684\u6a21\u5f0f\u4e00\u79cd<\/h4>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/49-0.png\" alt=\"\u30d3\u30eb\u30c94.png\" \/><\/div>\n<pre class=\"post-pre\"><code><span class=\"k\">FROM<\/span><span class=\"s\"> postgres:9.6<\/span>\r\n\r\n<span class=\"k\">RUN <\/span>psql <span class=\"nt\">-d<\/span> postgres <span class=\"nt\">--username<\/span> postgres <span class=\"nt\">-c<\/span> <span class=\"s2\">\"create table public.user (name varchar)\"<\/span> <span class=\"se\">\\\r\n<\/span>  <span class=\"o\">&amp;&amp;<\/span> psql <span class=\"nt\">-d<\/span> postgres <span class=\"nt\">--username<\/span> postgres <span class=\"nt\">-c<\/span> <span class=\"s2\">\"insert into public.user (name) values (\"<\/span>taro<span class=\"s2\">\")\"<\/span>\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>PS&gt; docker build -t test .\r\n\r\nSending build context to Docker daemon  2.048kB\r\nStep 1\/2 : FROM postgres:9.6\r\n ---&gt; f8d91fbcfa35\r\nStep 2\/2 : RUN psql -d postgres --username postgres -c \"create table public.user (name varchar)\"   &amp;&amp; psql -d postgres --username postgres -c \"insert into public.user (name) values (\"taro\")\"\r\n ---&gt; Running in 9af317a881ca\r\npsql: could not connect to server: No such file or directory\r\n        Is the server running locally and accepting\r\n        connections on Unix domain socket \"\/var\/run\/postgresql\/.s.PGSQL.5432\"?\r\n<\/code><\/pre>\n<p>\u55ef\uff0c\u5176\u5b9e\u4e00\u5f00\u59cb\u5c31\u6ca1\u6709\u8054\u901a\u3002<\/p>\n<h5>\u25cf \u4e2d\u95f4\u4ef6\u7684\u521d\u59cb\u5316\u4e4b\u96be<\/h5>\n<p>\u4e8b\u5b9e\u4e0a\uff0cDocker \u7684\u6700\u4f73\u5b9e\u8df5\u662f\u5728\u8fd0\u884c\u6216\u542f\u52a8\u65f6\u4e3a\u6bcf\u4e2a\u5bb9\u5668\u542f\u52a8\u4e00\u4e2a\u8fdb\u7a0b\u3002<br \/>\n\u5728\u8fdb\u884c psql \u65f6\uff0cPostgreSQL \u8fd8\u6ca1\u6709\u542f\u52a8\uff0c\u4e5f\u6ca1\u6709\u8fdb\u884c initdb\u3002<br \/>\nMySQL \u548c MariaDB \u4e5f\u6709\u7c7b\u4f3c\u7684\u884c\u4e3a\u3002<\/p>\n<p>\u6211\u8ba4\u4e3a\u8fd9\u53ef\u80fd\u662f\u5fae\u670d\u52a1\u6700\u4f73\u5b9e\u8df5\uff0c\u5e76\u4e14Docker\u662f\u4e3a\u6b64\u800c\u8bbe\u8ba1\u7684\uff08docker run ~:stdout \u2192 docker log\uff0cdocker run -it ~:stdin \u2190 tty\uff09\u3002<\/p>\n<p>\u5982\u679c\u6309\u7167\u8fd9\u4e2a\u539f\u7406\u548c\u539f\u5219\uff0c\u4f3c\u4e4e\u6ce8\u5165\u72b6\u6001\u7684\u65b9\u5f0f\u4e8c\u5728\u542f\u52a8\u540e\u66f4\u597d\u3002<\/p>\n<p>\u6709\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u4f1a\u5f3a\u884c\u5728\u6784\u5efa Docker \u955c\u50cf\u65f6\u6267\u884c docker-entrypoint.sh (\u5728 docker \u8fd0\u884c\u65f6\u8fd0\u884c\u7684shell\u811a\u672c)\uff0c\u4f46\u8fd9\u4ecd\u7136\u6709\u4e9b\u52c9\u5f3a\u3002<\/p>\n<h4>1. \u5bf9\u5df2\u542f\u52a8\u7684\u5bb9\u5668\u8fdb\u884c\u4fee\u6539\u7684\u6a21\u5f0f\u3002<\/h4>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/59-0.png\" alt=\"\u30d3\u30eb\u30c93.png\" \/><\/div>\n<p>\u8bd5\u8bd5\u5728\u542f\u52a8\u540e\u8fdb\u884c\u66f4\u6539\u5e76\u4fdd\u5b58\u7684\u65b9\u6cd5\u3002<\/p>\n<pre class=\"post-pre\"><code>PS&gt; docker run -d --name db -e POSTGRES_PASSWORD=password postgres:9.6\r\nPS&gt; docker exec db psql -U postgres -c \"create table public.user (name varchar)\"\r\nPS&gt; docker exec db psql -U postgres -c \"insert into public.user (name) values ('taro')\"\r\nPS&gt;  docker exec db psql -U postgres -c \"select * from public.user\"\r\n name\r\n------\r\n taro\r\n(1 row)\r\n<\/code><\/pre>\n<p>\u5c06\u5176\u6ce8\u518c\u4e3a\u4e00\u4e2a\u540d\u4e3a&#8221;initeddb&#8221;\u7684\u65b0\u6620\u50cf\u3002<\/p>\n<pre class=\"post-pre\"><code>PS&gt; docker commit db initeddb\r\nPS&gt; docker images\r\n\r\nREPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE\r\niniteddb                   latest              1tiedea87262        7 seconds ago       269MB\r\n...\r\n<\/code><\/pre>\n<p>\u6240\u4ee5\uff0c\u91cd\u65b0\u542f\u52a8\u4e00\u4e0b\uff0c\u770b\u770b\u6548\u679c\u3002<\/p>\n<pre class=\"post-pre\"><code>PS&gt; docker stop db ; docker rm -f db\r\n\r\nPS&gt; docker run -d --name new_db initeddb:latest\r\nPS&gt; docker exec new_db psql -U postgres -c \"select * from public.user\"\r\nERROR:  relation \"public.user\" does not exist\r\nLINE 1: select * from public.user\r\n\r\n<\/code><\/pre>\n<p>\u5df2\u7ecf\u6d88\u5931\u4e86&#8230;<\/p>\n<h5>\u25cf VOLUME \u7684\u9677\u9631<\/h5>\n<p>\u5b9e\u9645\u4e0a\uff0c\u5f53\u4f60\u67e5\u770bPostgreSQL\u5b98\u65b9\u955c\u50cf\u7684Dockerfile\u65f6\uff0c\u4f60\u4f1a\u770b\u5230`VOLUME \/var\/lib\/postgresql\/data`\u8fd9\u6837\u7684\u63cf\u8ff0\u3002<\/p>\n<p>\u8fd9\u610f\u5473\u7740 PostgreSQL \u7684\u66f4\u6539\u4fdd\u5b58\u5728\u6570\u636e\u5377\u4e2d\uff0c\u800c\u4e0d\u4fdd\u5b58\u5728\u4e3b\u5bb9\u5668\u4e2d\uff08\u8be6\u7ec6\u4fe1\u606f\uff09\u3002<\/p>\n<p>\u8fd9\u5b9e\u9645\u4e0a\u662f\u6e90\u81ea\u5b98\u65b9\u5bf9\u4e8e\u4e0d\u5305\u542b\u6570\u636e\u7684\u575a\u51b3\u610f\u613f\u3002<br \/>\n\u867d\u7136\u53ef\u4ee5\u901a\u8fc7\u81ea\u5df1\u7f16\u5199 Dockerfile \u6765\u907f\u514d\u8fd9\u4e00\u70b9\uff0c\u4f46\u6211\u5f88\u597d\u5947\u4e3a\u4ec0\u4e48\u4f1a\u5982\u6b64\u5f3a\u70c8\u5730\u4e0d\u5e0c\u671b\u5305\u542b\u6570\u636e\u3002<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u4e0d\u5c06\u6570\u636e\u5e93\u72b6\u6001\u5305\u542b\u5728\u56fe\u50cf\u4e2d\uff1f<\/h3>\n<p>\u6b63\u5728\u8fdb\u884c\u4e2d&#8230;<\/p>\n<h3>2. \u5b89\u88c5\u5783\u573e\u8f66<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/74-0.png\" alt=\"mount10.png\" \/><\/div>\n<p>\u5b9e\u9645\u4e0a\uff0c\u5b98\u65b9\u63d0\u4f9b\u4e86\u4e00\u79cd\u6062\u590d\u6570\u636e\u7684\u65b9\u6cd5\u3002<br \/>\n\u5b83\u53ef\u4ee5\u5728\u542f\u52a8\u65f6\u8bfb\u53d6\u653e\u7f6e\u5728\u6307\u5b9a\u6587\u4ef6\u5939\u4e2d\u7684 *.sql, *.sql.gz \u6587\u4ef6\u3002<\/p>\n<p>\u5728PostgreSQL\u4e2d\uff0c\u5982\u679c\u5c06\u8f6c\u50a8\u6587\u4ef6\u653e\u7f6e\u5728\u7279\u5b9a\u7684\u6587\u4ef6\u5939\uff08\/var\/lib\/postgresql\/data\uff09\uff0c\u5219\u5728\u4f7f\u7528docker run\u65f6\u4f1a\u81ea\u52a8\u52a0\u8f7d\u3002<\/p>\n<h4>\u25cf \u4f18\u70b9<\/h4>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u516c\u5f0f\u306b\u63a8\u5968\u3055\u308c\u305f\u624b\u6cd5<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30a4\u30e1\u30fc\u30b8\u3092\u3044\u304f\u3064\u3082\u7ba1\u7406\u3059\u308b\u5fc5\u8981\u304c\u7121\u3044<\/ul>\n<\/li>\n<\/ul>\n<p>\u305d\u306e\u4ee3\u308f\u308a\u3001\u30c0\u30f3\u30d7\u306f\u3044\u304f\u3064\u3082\u7ba1\u7406\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u5171\u6709\u3059\u308b\u3053\u3068\u3067\u30c1\u30fc\u30e0\u3067\u74b0\u5883\u5171\u6709\u304c\u53ef\u80fd<\/p>\n<h4>\u25c6 \u7f3a\u70b9<\/h4>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u8d77\u52d5\u6642\u306b\u8aad\u307f\u8fbc\u307e\u308c\u308b\u306e\u304c\u9045\u3044<\/ul>\n<\/li>\n<\/ul>\n<p>docker run \u304c\u7d42\u308f\u3063\u3066\u3082\u3001\u88cf\u3067\u306fRestore \u304c\u8d70\u3063\u3066\u3044\u3066\u3001\u305d\u308c\u304c\u7d42\u308f\u308b\u307e\u3067\u63a5\u7d9a\u3067\u304d\u306a\u3044<\/p>\n<p>\u5b8c\u5168\u306a Immutable \u3058\u3083\u306a\u3044<br \/>\n\u30c0\u30f3\u30d7\u30d5\u30a1\u30a4\u30eb\u7ba1\u7406\u3092\u81ea\u5206\u305f\u3061\u3067\u3057\u306a\u304f\u3066\u306f\u884c\u3051\u306a\u3044<\/p>\n<h3>3. \u5728\u6570\u636e\u91cf\u4e0a\u4fdd\u6301\u4e0d\u53d8\uff0c\u8fdb\u884c\u6301\u7eed\u5316\u548c\u5171\u4eab<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/82-0.png\" alt=\"mount11.png\" \/><\/div>\n<p>\u5229\u7528 Volume \u529f\u80fd\u5c06\u6570\u636e\u6587\u4ef6\u5939\u4f5c\u4e3a\u6302\u8f7d\u70b9\uff0c\u5373\u4f7f\u5e94\u7528\u5bb9\u5668\u5d29\u6e83\uff0c\u6570\u636e\u4ecd\u7136\u53ef\u4ee5\u4fdd\u7559\u4e0b\u6765\u3002<\/p>\n<h4>\u25c6 \u4f18\u70b9<\/h4>\n<ul class=\"post-ul\">\u8d77\u52d5\u304c\u65e9\u3044<\/ul>\n<h4>\u25c6 \u4f18\u52bf<\/h4>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">2 \u3068\u306e\u9055\u3044\u304c\u7121\u3044<\/ul>\n<\/li>\n<\/ul>\n<p>\u5171\u6709\u30fb\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u304c\u5fc5\u8981<br \/>\n\u305d\u306e\u304f\u305b<\/p>\n<p>\u516c\u5f0f\u304c\u63a8\u5968\u3057\u305f\u3084\u308a\u65b9\u3067\u306f\u306a\u3044<br \/>\n\u624b\u9806\u304c\u591a\u3044<\/p>\n<p>\u4f3c\u4e4e\u6ca1\u6709\u79ef\u6781\u9009\u62e9\u7684\u7406\u7531\u3002<\/p>\n<h1>\u4f5c\u4e3a Docker \u7684\u89e3\u51b3\u65b9\u6848\uff0c\u4f46\u91c7\u7528\u4e86\u4e0d\u540c\u7684\u65b9\u6cd5\u3002<\/h1>\n<p>\u53ef\u4ee5\u5728\u4f7f\u7528 Docker \u529f\u80fd\u7684\u540c\u65f6\uff0c\u4ece\u7565\u6709\u4e0d\u540c\u7684\u89d2\u5ea6\u8fdb\u884c\u653b\u51fb\u3002<br \/>\n\u53ef\u4ee5\u5229\u7528\u8fdc\u7a0b\u6587\u4ef6\u7cfb\u7edf\u6216\u5206\u5e03\u5f0f\u6587\u4ef6\u7cfb\u7edf\u3002<\/p>\n<h2>\u8fdc\u7a0b\u6587\u4ef6\u7cfb\u7edf<\/h2>\n<p>\u6709\u4e9b\u4eba\u4e5f\u5c1d\u8bd5\u76f4\u63a5\u6302\u8f7dNFS\u6216Samba\/CIFS\u5230Docker\u7684\u6570\u636e\u5377\u4e0a\u3002<\/p>\n<p>\u5c1d\u8bd5\u4f7f\u7528\u6700\u65b0\u7684Docker\u529f\u80fd\uff1a\u4e86\u89e3Docker\u7684\u5377\u63d2\u4ef6\u548c\u5b58\u50a8\u9a71\u52a8\u7a0b\u5e8f\u3002<\/p>\n<h2>\u5206\u5e03\u5f0f\u6587\u4ef6\u7cfb\u7edf<\/h2>\n<p>\u5728Ceph\u3001GlusterFS\u3001flocker\u7b49\u6280\u672f\u4e2d\uff0c\u4e5f\u6709\u5c1d\u8bd5\u5c06\u6570\u636e\u5377\u8fdb\u884c\u5206\u5e03\u5f0f\u5904\u7406\u7684\u52aa\u529b\u3002<\/p>\n<h2>\u80fd\u6210\u4e3a\u89e3\u51b3\u65b9\u6848\u5417\uff1f<\/h2>\n<p>\u4e0d\u8fc7\uff0c\u7531\u4e8e\u6574\u4f53\u800c\u8a00\uff0c\u5b83\u4e0e\u9664\u4e86Docker\u4ee5\u5916\u7684\u89e3\u51b3\u65b9\u6848\u90fd\u9762\u4e34\u540c\u6837\u7684\u95ee\u9898\uff0c\u6240\u4ee5\u8fd9\u6b21\u6211\u9009\u62e9\u5c06\u5176\u6392\u9664\u5728\u5916\u3002<\/p>\n<h1>\u6700\u7ec8\uff0c\u54ea\u4e00\u4e2a\u662f\u6700\u597d\u7684\uff1f<\/h1>\n<p>\u76ee\u524d\u91c7\u7528\u7b2c\u4e8c\u79cd\u65b9\u6cd5<\/p>\n<h1>\u5f00\u53d1\u6d41\u7a0b\u4f1a\u600e\u6837\u53d1\u5c55\u5462\uff1f<\/h1>\n<p>\u8bf7\u603b\u7ed3\u4e00\u4e0b\u8fd9\u4e2a\u5b9e\u9645\u7684\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n<h2>\u521b\u5efa\u6570\u636e\u5e93\u7ba1\u7406\u9879\u76ee\u3002<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/103-0.png\" alt=\"p1.png\" \/><\/div>\n<p>\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u4e13\u95e8\u7ba1\u7406\u6570\u636e\u5e93\u7684\u9879\u76ee\u3002<\/p>\n<p>\u6211\u5011\u5728\u90a3\u88e1\u4e3b\u8981\u8ca0\u8cac\u7ba1\u7406\u4e09\u500b\u89d2\u8272\u3002<\/p>\n<h3>\u89d2\u82721. \u67b6\u6784\u7ba1\u7406<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/107-0.png\" alt=\"p2.png\" \/><\/div>\n<p>\u76ee\u524d\uff0c\u6211\u5011\u7d93\u904e\u4e00\u4e9b\u8a66\u9a57\uff0c\u767c\u73fe\u4f7f\u7528 ridgepole \u4f86\u7ba1\u7406\u8cc7\u6599\u5eab\u7684\u67b6\u69cb\u662f\u6700\u597d\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u901a\u8fc7Ridgepole\u7684\u4ee3\u7801\u6765\u8fdb\u884c\u6a21\u5f0f\uff08schema\uff09\u7684\u7248\u672c\u63a7\u5236\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"n\">create_table<\/span> <span class=\"s2\">\"users\"<\/span><span class=\"p\">,<\/span> <span class=\"ss\">force: :cascade<\/span> <span class=\"k\">do<\/span> <span class=\"o\">|<\/span><span class=\"n\">t<\/span><span class=\"o\">|<\/span>\r\n  <span class=\"n\">t<\/span><span class=\"p\">.<\/span><span class=\"nf\">string<\/span>   <span class=\"s2\">\"name\"<\/span>          <span class=\"p\">,<\/span><span class=\"ss\">null: <\/span><span class=\"kp\">false<\/span>\r\n  <span class=\"n\">t<\/span><span class=\"p\">.<\/span><span class=\"nf\">string<\/span>   <span class=\"s2\">\"display_name\"<\/span>  <span class=\"p\">,<\/span><span class=\"ss\">null: <\/span><span class=\"kp\">false<\/span>\r\n\r\n  <span class=\"n\">t<\/span><span class=\"p\">.<\/span><span class=\"nf\">datetime<\/span> <span class=\"s2\">\"created_at\"<\/span>    <span class=\"p\">,<\/span><span class=\"ss\">null: <\/span><span class=\"kp\">false<\/span>\r\n  <span class=\"n\">t<\/span><span class=\"p\">.<\/span><span class=\"nf\">datetime<\/span> <span class=\"s2\">\"updated_at\"<\/span>    <span class=\"p\">,<\/span><span class=\"ss\">null: <\/span><span class=\"kp\">false<\/span>\r\n<span class=\"k\">end<\/span>\r\n\r\n<span class=\"n\">create_table<\/span> <span class=\"s2\">\"offices\"<\/span><span class=\"p\">,<\/span> <span class=\"ss\">force: :cascade<\/span> <span class=\"k\">do<\/span> <span class=\"o\">|<\/span><span class=\"n\">t<\/span><span class=\"o\">|<\/span>\r\n  <span class=\"n\">t<\/span><span class=\"p\">.<\/span><span class=\"nf\">string<\/span>   <span class=\"s2\">\"name\"<\/span>           <span class=\"p\">,<\/span><span class=\"ss\">null: <\/span><span class=\"kp\">false<\/span>\r\n  <span class=\"n\">t<\/span><span class=\"p\">.<\/span><span class=\"nf\">string<\/span>   <span class=\"s2\">\"address\"<\/span>           <span class=\"p\">,<\/span><span class=\"ss\">null: <\/span><span class=\"kp\">false<\/span>\r\n\r\n  <span class=\"n\">t<\/span><span class=\"p\">.<\/span><span class=\"nf\">datetime<\/span> <span class=\"s2\">\"created_at\"<\/span>     <span class=\"p\">,<\/span><span class=\"ss\">null: <\/span><span class=\"kp\">false<\/span>\r\n  <span class=\"n\">t<\/span><span class=\"p\">.<\/span><span class=\"nf\">datetime<\/span> <span class=\"s2\">\"updated_at\"<\/span>     <span class=\"p\">,<\/span><span class=\"ss\">null: <\/span><span class=\"kp\">false<\/span>\r\n<span class=\"k\">end<\/span>\r\n<span class=\"o\">...<\/span>\r\n<\/code><\/pre>\n<h3>\u7ba1\u7406\u865b\u5047\u6578\u64da\u50be\u5378\u7684\u89d2\u8272\u3002<\/h3>\n<p>\u63a5\u4e0b\u6765\uff0c\u6b63\u5728\u8fdb\u884c\u521b\u5efa\u5f00\u53d1\u7528\u865a\u62df\u6570\u636e\u8f6c\u50a8\u7684\u6570\u636e\u5e93\u542f\u52a8\u3002<\/p>\n<h4>01_schema.sql \uff1a\u57fa\u7840\u67b6\u6784\u7684\u8f6c\u50a8<\/h4>\n<p>Ridgepole\u7684Schema\u5728CI\u65f6\u4f1a\u8f6c\u5316\u4e3aSQL\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/115-0.png\" alt=\"p3.png\" \/><\/div>\n<h4>02_dummy.sql: \u6570\u636e\u5907\u4efd<\/h4>\n<p>\u5173\u4e8e\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u8fd8\u6ca1\u6709\u5b8c\u5168\u786e\u5b9a\u6211\u7684\u60f3\u6cd5\u3002<br \/>\n\u76ee\u524d\uff0c\u6211\u5c06\u5b83\u5206\u4e3a\u4e24\u4e2a\u9636\u6bb5\u8fdb\u884c\u5b9e\u65bd\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/118-0.png\" alt=\"p6.png\" \/><\/div>\n<p>\u25cf \u9636\u6bb51\uff1a\u4f7f\u7528CSV\u8fdb\u884cCOPY<\/p>\n<p>\u5982\u679c\u662f\u4e3b\u6d41\u7cfb\uff0c\u7531\u4e8e\u6570\u91cf\u8f83\u5c11\uff0c\u53ef\u4ee5\u4f7f\u7528CSV\u8fdb\u884c\u7ba1\u7406\uff0c\u5e76\u901a\u8fc7COPY\u8fdb\u884c\u8f93\u5165\u3002\u8fd9\u662f\u624b\u52a8\u64cd\u4f5c\u3002<\/p>\n<p>\u25cf \u9636\u6bb52\uff1a\u4f7f\u7528Python + Pandas\u521b\u5efa\u6570\u636e<\/p>\n<p>\u5982\u679c\u6d89\u53ca\u6570\u636e\u76f8\u5173\u7684\u8bdd\uff0c\u6570\u91cf\u4e5f\u76f8\u5e94\u9700\u8981\u4e00\u5b9a\u91cf\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u4f1a\u5c06\u5176\u62c6\u5206\u4e3a\u4e00\u4e2a\u72ec\u7acb\u7684\u9879\u76ee\uff0c\u4f7f\u7528Python\u624b\u52a8\u5236\u9020\u5927\u91cf\u7684\u865a\u62df\u6570\u636e\u3002<\/p>\n<h3>\u89d2\u82723\uff1a\u5783\u573e\u8f66\u7684\u5171\u4eab<\/h3>\n<p>\u6211\u4eec\u7528\u89d2\u82722\u5236\u4f5c\u7684\u8f6c\u50a8\u6587\u4ef6\u5e94\u8be5\u5982\u4f55\u5171\u4eab\uff1f<br \/>\n\u76ee\u524d\uff0c\u7531\u4e8e\u56e2\u961f\u6210\u5458\u90fd\u53ef\u4ee5\u8bbf\u95ee\u5e76\u4e14\u8fdb\u884c\u8bbf\u95ee\u7ba1\u7406\u7684\u539f\u56e0\uff0c\u6211\u4eec\u4f7f\u7528Google Drive\u8fdb\u884c\u624b\u52a8\u5171\u4eab\u3002<\/p>\n<p>\u65e0\u8bba\u662f\u5728S3\u8fd8\u662fDropbox\uff0c\u6211\u89c9\u5f97\u90fd\u662f\u4e00\u6837\u7684\uff0c\u4f46\u8fd9\u5f88\u56f0\u96be\u3002<\/p>\n<h2>2. \u5728\u6bcf\u4e2a\u9879\u76ee\u4e2d\u83b7\u53d6\u865a\u62df\u8f6c\u50a8\u6587\u4ef6\u3002<\/h2>\n<p>\u6bcf\u4e2a\u5f00\u53d1\u8005\u90fd\u4f1a\u4e0b\u8f7d\u6bcf\u4e2a\u9879\u76ee\uff0c\u5e76\u5c06\u5176\u653e\u7f6e\u5728\u7279\u5b9a\u7684\u4f4d\u7f6e\u5e76\u542f\u52a8\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"na\">services<\/span><span class=\"pi\">:<\/span>\r\n  <span class=\"na\">db<\/span><span class=\"pi\">:<\/span>\r\n    <span class=\"na\">container_name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">postgres<\/span>\r\n    <span class=\"na\">image<\/span><span class=\"pi\">:<\/span> <span class=\"s\">postgres:9.5<\/span>\r\n    <span class=\"na\">ports<\/span><span class=\"pi\">:<\/span>\r\n      <span class=\"pi\">-<\/span> <span class=\"s2\">\"<\/span><span class=\"s\">5432:5432\"<\/span>\r\n    <span class=\"na\">volumes<\/span><span class=\"pi\">:<\/span>\r\n      <span class=\"pi\">-<\/span> <span class=\"s\">.\/dump\/db:\/docker-entrypoint-initdb.d<\/span>\r\n    <span class=\"na\">environment<\/span><span class=\"pi\">:<\/span>\r\n      <span class=\"pi\">-<\/span> <span class=\"s\">POSTGRES_USER=test<\/span>\r\n      <span class=\"pi\">-<\/span> <span class=\"s\">POSTGRES_PASSWORD=test<\/span>\r\n      <span class=\"pi\">-<\/span> <span class=\"s\">POSTGRES_DB=test_db<\/span>\r\n    <span class=\"na\">networks<\/span><span class=\"pi\">:<\/span>\r\n      <span class=\"pi\">-<\/span> <span class=\"s\">default<\/span>\r\n<\/code><\/pre>\n<h1>\u6211\u73b0\u5728\u6b63\u5728\u8003\u8651\u7684\u4e8b\u60c5<\/h1>\n<h2>\u6211\u60f3\u8981\u6539\u53d8\u6587\u4ef6\u5171\u4eab\u7684\u65b9\u5f0f\u3002<\/h2>\n<p>\u6709\u6ca1\u6709\u4e00\u79cd\u80fd\u591f\u81ea\u52a8\u5171\u4eab\u56e2\u961f\u4e4b\u95f4\u3001\u8fdb\u884c\u7248\u672c\u7ba1\u7406\u7684\u5927\u6570\u636e\u65b9\u6cd5\uff1f\u867d\u7136\u6709\u51e0\u4e2a\u5019\u9009\u65b9\u6848\uff0c\u4f46\u4ecd\u5904\u4e8e\u8c03\u67e5\u548c\u8bc4\u4f30\u9636\u6bb5\u3002<\/p>\n<h3>\u4f7f\u7528 Git LFS<\/h3>\n<p>\u5e72\u8106\u7528Git\u6765\u7ba1\u7406\u4e0d\u662f\u633a\u597d\u7684\u5417\uff1f<\/p>\n<p>\u8fd8\u5728\u8fdb\u884c\u4e2d&#8230;<\/p>\n<h3>\u4f7f\u7528 &#8220;noms&#8221;<\/h3>\n<p>\u6211\u4e4b\u524d\u4e00\u76f4\u5728\u60f3\uff0c\u8981\u662f\u6570\u636e\u5e93\u672c\u8eab\u80fd\u63d0\u4f9b\u7248\u672c\u63a7\u5236\u5c31\u597d\u4e86\u3002\u7136\u540e\u6211\u53d1\u73b0\u4e86\u4e00\u4e2a\u53ebnorm\u7684\u770b\u8d77\u6765\u5f88\u4e0d\u9519\u3002<\/p>\n<p>\u6807\u51c6<\/p>\n<p>\u5c3d\u7ba1\u6211\u8fd8\u6ca1\u5f00\u59cb\u4f7f\u7528\u8fc7\uff0c\u4f46\u5982\u679c\u8fd9\u4e2a\u53ef\u4ee5\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\uff0c\u90a3\u4e48\u5b83\u53ef\u80fd\u53ef\u4ee5\u89e3\u51b3\u4e00\u4e9b\u4e0d\u662fDocker\u7684\u89e3\u51b3\u65b9\u6848\u7684\u95ee\u9898\u5427\u3002<\/p>\n<p>\u53c2\u8003: \u6211\u4eec\u6765\u8bd5\u8bd5\u5177\u6709\u6570\u636e\u7248\u672c\u63a7\u5236\u80fd\u529b\u7684\u5206\u5e03\u5f0f\u6570\u636e\u5e93Noms\u3002<\/p>\n<h1>\u6709\u5173\u4fe1\u606f<\/h1>\n<h2>\u25c6 \u4f7f\u7528 Docker \u8fdb\u884c\u5377\u7ba1\u7406<\/h2>\n<p>\u4e25\u683c\u6765\u8bf4\uff0c\u5377\u7ba1\u7406\u5927\u81f4\u53ef\u4ee5\u5206\u4e3a\u4e24\u79cd\u65b9\u6cd5\u3002<\/p>\n<h3>\u5728\u4e3b\u673a\u4e0a\u81ea\u884c\u7ba1\u7406<\/h3>\n<p>\u5c06\u4e3b\u673a\u6307\u5b9a\u7684\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\u4e2d\u7684\u65b9\u6cd5\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/145-0.png\" alt=\"mount02.png\" \/><\/div>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>docker run <span class=\"nt\">-d<\/span> <span class=\"nt\">--name<\/span> db <span class=\"nt\">-v<\/span> <span class=\"s2\">\"\/path\/to\/data:\/var\/lib\/postgresql\/data\"<\/span> postgres:9.6\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u6837\u505a\uff0c\u4e3b\u673a\u4e0a\u7684 \/path\/to\/data \u5c06\u88ab\u6302\u8f7d\u5230 \/var\/lib\/postgresql\/data\uff0c\u5e76\u4e14\u6570\u636e\u5c06\u5728 \/path\/to\/data \u4e0b\u4fdd\u5b58\u5e76\u6301\u4e45\u5316\u3002<\/p>\n<p>\u8fd9\u5c06\u5bfc\u81f4\u4e3b\u673a\u7684 \/path\/to\/data \u88ab\u6302\u8f7d\u5230 \/var\/lib\/postgresql\/data\uff0c\u5e76\u4e14\u6570\u636e\u5c06\u5728 \/path\/to\/data \u4e0b\u4fdd\u5b58\u5e76\u6301\u4e45\u5316\u3002<\/p>\n<p>\u8fd9\u4e00\u6b65\u9aa4\u5c06\u4f7f\u4e3b\u673a\u7684 \/path\/to\/data \u88ab\u6302\u8f7d\u5230 \/var\/lib\/postgresql\/data\uff0c\u5728 \/path\/to\/data \u4e0b\u4fdd\u5b58\u5e76\u6c38\u4e45\u4fdd\u7559\u6570\u636e\u3002<\/p>\n<p>\u7ecf\u8fc7\u8fd9\u4e00\u6b65\uff0c\u4e3b\u673a\u4e0a\u7684 \/path\/to\/data \u5c06\u4f1a\u6302\u8f7d\u5230 \/var\/lib\/postgresql\/data\uff0c\u5e76\u4e14\u6570\u636e\u5c06\u5728 \/path\/to\/data \u4e0b\u4fdd\u5b58\u5e76\u6301\u4e45\u5316\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>docker <span class=\"nb\">exec <\/span>db psql <span class=\"nt\">-U<\/span> postgres <span class=\"nt\">-c<\/span> <span class=\"s2\">\"create table public.user (name varchar)\"<\/span>\r\n<span class=\"nv\">$ <\/span>docker <span class=\"nb\">exec <\/span>db psql <span class=\"nt\">-U<\/span> postgres <span class=\"nt\">-c<\/span> <span class=\"s2\">\"insert into public.user (name) values ('taro')\"<\/span>\r\n<span class=\"nv\">$ <\/span>docker stop db <span class=\"p\">;<\/span> docker <span class=\"nb\">rm<\/span> <span class=\"nt\">-f<\/span> db\r\n\r\n<span class=\"c\"># \u540c\u3058\u30db\u30b9\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u30de\u30a6\u30f3\u30c8\u3057\u3066\u5b9f\u884c<\/span>\r\n<span class=\"nv\">$ <\/span>docker run <span class=\"nt\">-d<\/span> <span class=\"nt\">--name<\/span> new_db <span class=\"nt\">-v<\/span> <span class=\"s2\">\"\/path\/to\/data:\/var\/lib\/postgresql\/data\"<\/span> postgres:9.6\r\n<span class=\"nv\">$ <\/span>docker <span class=\"nb\">exec <\/span>new_db psql <span class=\"nt\">-U<\/span> postgres <span class=\"nt\">-c<\/span> <span class=\"s2\">\"select * from public.user\"<\/span>\r\n name\r\n<span class=\"nt\">------<\/span>\r\n taro\r\n<span class=\"o\">(<\/span>1 row<span class=\"o\">)<\/span>\r\n<\/code><\/pre>\n<p>\u7531\u4e8e\u6240\u6709\u6743\u7684\u5173\u7cfb\uff0c\u5728Windows\u4e0a\u65e0\u6cd5\u8fd0\u884c\uff0c\u4f46\u81f3\u5c11\u80fd\u611f\u53d7\u5230\u4e00\u70b9\u6c1b\u56f4\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u4fdd\u5b58\u5148\u3092\u660e\u793a\u3059\u308b\u306e\u3067\u3001\u76f4\u611f\u7684\u3067\u5206\u304b\u308a\u3084\u3059\u3044<\/ul>\n<\/li>\n<\/ul>\n<p>\u30c7\u30fc\u30bf\u306e\u7ba1\u7406\u306f\u3001\u5229\u7528\u8005\u306b\u4efb\u3055\u308c\u308b<\/p>\n<p>\u300e\u3069\u308c\u304c\u4f55\u306e\u30c7\u30fc\u30bf\u304b\u300f\u306a\u3069\u306e\u30e1\u30bf\u30c7\u30fc\u30bf\u7ba1\u7406<br \/>\n\u30b4\u30df\u30c7\u30fc\u30bf\u306e\u524a\u9664<\/p>\n<h3>2. \u6570\u636e\u91cf<\/h3>\n<p>\u5728Docker\u7ba1\u63a7\u7684\u9886\u57df\u4e2d\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u5e76\u5c06\u5176\u7528\u5bb9\u5668\u6302\u8f7d\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/153-0.png\" alt=\"mount03.png\" \/><\/div>\n<pre class=\"post-pre\"><code>PS&gt; docker volume create --name my_data\r\nPS&gt; docker run -d -v my_data:\/var\/lib\/postgresql\/data postgres:9.6\r\n<\/code><\/pre>\n<p>\u8fd9\u6837\u4e00\u6765\uff0c\u4e00\u4e2a\u540d\u4e3a my_data \u7684\u6570\u636e\u5377\u5c31\u521b\u5efa\u4e86\uff0c\u5b83\u4f1a\u6302\u8f7d\u5230\u5bb9\u5668\u7684 \/var\/lib\/postgresql\/data \u76ee\u5f55\u4e0b\u3002<\/p>\n<p>\u5982\u679c\u662fWindows\u64cd\u4f5c\u7cfb\u7edf\uff0cData Volume \u5c06\u88ab\u521b\u5efa\u5728Moby Linux\u865a\u62df\u673a\u7684\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\/var\/lib\/docker\/volumes\/\u76ee\u5f55\u4e0b\uff0c\u4ee5&lt;&lt;\u54c8\u5e0c\u503c&gt;&gt;\/_data\u547d\u540d\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Docker \u304c\u7ba1\u7406\u3057\u3066\u304f\u308c\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>docker volume ~ \u30b5\u30d6\u30b3\u30de\u30f3\u30c9\u3067\u64cd\u4f5c\u3067\u304d\u308b<\/p>\n<p>\u901a\u5e38\u306e\u30b3\u30f3\u30c6\u30ca\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u30a4\u30e1\u30fc\u30b8\u306e\u4fdd\u5b58\u306f\u3067\u304d\u306a\u3044<\/p>\n<p>Data Volume \u3092\u30de\u30a6\u30f3\u30c8\u3057\u3066\u4e2d\u8eab\u3092 tar \u3067\u4fdd\u5b58\u3059\u308b\u3068\u8a00\u3046\u624b\u6cd5\u3082\u3042\u308b\u306b\u306f\u3042\u308b<\/p>\n<p>\u7136\u540e\uff0c\u5c31\u7b97\u4f7f\u7528\u6570\u636e\u91cf\uff0c\u4e5f\u6709\u51e0\u79cd\u4e0d\u540c\u7684\u7528\u6cd5\u3002<\/p>\n<h4>\u7ed9\u4e00\u4e2aDocker\u5377\u547d\u540d\u4ee5\u8fdb\u884c\u7ba1\u7406\u3002<\/h4>\n<p>\u7531\u4e8e\u53ef\u4ee5\u81ea\u884c\u6307\u5b9a\u540d\u79f0\uff0c\u5e76\u4e14\u7ba1\u7406\u53ef\u4ea4\u7ed9 Docker\uff0c\u6240\u4ee5\u975e\u5e38\u65b9\u4fbf\u4f7f\u7528\u3002<\/p>\n<pre class=\"post-pre\"><code>PS&gt; docker volume create --name my_data\r\nPS&gt; docker volume ls\r\n\r\nDRIVER              VOLUME NAME\r\nlocal               my_data\r\n\r\nPS&gt; docker volume rm my_data\r\n<\/code><\/pre>\n<p>\u7528\u6765\u505a\u4ec0\u4e48\uff1f<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c7\u30fc\u30bf\u306e\u6c38\u7d9a\u5316<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30b3\u30f3\u30c6\u30ca\u9593\u3067 volume \u306e\u5171\u6709<\/ul>\n<h4>\u4f7f\u7528-bv &lt;&lt;\u8def\u5f84&gt;&gt;\u547d\u4ee4\u6765\u521b\u5efa\u4e34\u65f6\u6570\u636e\u5377\u3002<\/h4>\n<pre class=\"post-pre\"><code>PS&gt; docker run -d -v \/path\/to\/dir postgres:9.6\r\n<\/code><\/pre>\n<p>\u5f53\u6267\u884c\u6b64\u64cd\u4f5c\u65f6\uff0c\u5c06\u521b\u5efa\u4e00\u4e2aTemporary Data Volume\uff0c\u5e76\u4e14\u5c06\u5176\u6302\u8f7d\u5230\/path\/to\/dir\u3002<br \/>\n\u5f53\u5bb9\u5668\u5173\u95ed\u65f6\uff0c\u8fd9\u4e2aData Volume\u5c31\u4f1a\u53d8\u6210\u4e00\u4e2a\u65e0\u4eba\u5f15\u7528\u7684\u5f85\u5220\u9664\u7684&#8221;\u91ce\u826f&#8221;Data Volume\u3002<br \/>\n\uff08\u786e\u5207\u5730\u8bf4\uff0c\u5982\u679c\u6307\u5b9a\u4e86\u54c8\u5e0c\u503c\uff0c\u5219\u53ef\u4ee5\u5f15\u7528\u5b83\u3002\u5982\u679c\u4f60\u6709\u5174\u8da3\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u547d\u4ee4docker inspect | jq &#8220;.[0].Mounts&#8221;\u8fdb\u884c\u67e5\u8be2\u3002\uff09<\/p>\n<p>\u25c6 \u7528\u4e8e\u4ec0\u4e48\uff1f<\/p>\n<p>\u7ecf\u8fc7\u4e00\u756a\u8c03\u67e5\uff0c\u770b\u8d77\u6765<\/p>\n<p>docker commit \/ save\/ export \u3059\u308b\u4e0a\u3067\u90aa\u9b54\u306a\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u3092\u6368\u3066\u308b<br \/>\n\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b3\u30f3\u30c6\u30ca\u3092\u5727\u8feb\u3059\u308b\u7a0b\u306b\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u3092\u3067\u304d\u308b\u5834\u5408\u3001\u305d\u308c\u3092\u9694\u96e2\u3059\u308b<\/p>\n<p>\u770b\u8d77\u6765\u662f\u4e3a\u4e86\u4f7f\u7528\u800c\u51c6\u5907\u7684\u3002<\/p>\n<h4>2.c \u5728 Dockerfile \u4e2d\u4f7f\u7528 Volume \u547d\u4ee4\u3002<\/h4>\n<pre class=\"post-pre\"><code>...\r\n<span class=\"k\">VOLUME<\/span><span class=\"s\"> \/var\/lib\/postgresql\/data`<\/span>\r\n...\r\n<\/code><\/pre>\n<p>\u8fd9\u4e0e2.b\u76f8\u540c\uff0c\u5b83\u5728docker\u8fd0\u884c\u65f6\u521b\u5efa\u5e76\u6302\u8f7d\u4e34\u65f6\u6570\u636e\u5377\u3002<\/p>\n<p>\u25c6 \u7528\u9014\u662f\u4ec0\u4e48\uff1f<\/p>\n<p>\u867d\u7136\u76ee\u7684\u4e0e\u9009\u9879\u4e8c\u5341\u5206\u76f8\u4f3c\uff0c\u4f46\u8fd8\u6709\u53e6\u4e00\u4e2a\u91cd\u8981\u7684\u89d2\u8272\u662f\u5728docker\u6784\u5efa\u65f6\u9632\u6b62\u5305\u542b\u5728\u6620\u50cf\u4e2d\u3002<\/p>\n<h4>\u4ece-v\u53c2\u6570\u6765\u770b\uff0c\u5c06\u5176\u4ed6\u5bb9\u5668\u4f5c\u4e3a\u6570\u636e\u5377\u5bb9\u5668\u8fdb\u884c\u6302\u8f7d\u3002<\/h4>\n<p>\u6709\u4e00\u79cd\u53eb\u505a\u6570\u636e\u91cf\u5bb9\u5668\u7684\u65b9\u6cd5\u3002<br \/>\n\u5b83\u662f\u4e3a\u4e86\u516c\u5f00\u6570\u636e\u800c\u8bbe\u7acb\u7684\u5bb9\u5668\uff0c\u5176\u4ed6\u5229\u7528\u5bb9\u5668\u53ef\u4ee5\u4f7f\u7528 &#8211;volume-from \u6765\u4f7f\u7528\u5b83\u3002<\/p>\n<pre class=\"post-pre\"><code>PS&gt; docker run -d --name data_proxy -v \/path\/to\/data -v \/path\/to\/config busybox:latest\r\n\r\nPS&gt; docker run --name db1 --volume-from data_proxy postgres:9.6\r\nPS&gt; docker run --name db2 --volume-from data_proxy postgres:9.6\r\nPS&gt; docker run --name db3 --volume-from data_proxy postgres:9.6\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u6837\u505a\uff0cdb1\u3001db2\u548cdb3\u73b0\u5728\u5171\u4eab\u4e86\u4f4d\u4e8e\/path\/to\/data\u548c\/path\/to\/config\u7684\u6570\u636e\u548c\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>\u25c6 \u7528\u4e8e\u4ec0\u4e48\uff1f y\u00fa ?)<\/p>\n<p>\u6211\u4e0d\u77e5\u9053\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u203b \u8fd9\u662f\u5173\u4e8e\u4f7f\u7528Docker\u8fdb\u884c\u5f00\u53d1\u7684\u6587\u7ae0\u7684\u7eed\u7bc7\u3002 Immutability\u548c\u6570\u636e \u6211\u5728\u4e0a\u8ff0\u6587\u7ae0\u4e2d\u63d0\u5230\u4e86\u8fdb\u884c\u5468 [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-50572","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5982\u4f55\u4f7f\u7528Docker\u6765\u7ba1\u7406\u6570\u636e - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5982\u4f55\u4f7f\u7528docker\u6765\u7ba1\u7406\u6570\u636e\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5982\u4f55\u4f7f\u7528Docker\u6765\u7ba1\u7406\u6570\u636e\" \/>\n<meta property=\"og:description\" content=\"\u203b \u8fd9\u662f\u5173\u4e8e\u4f7f\u7528Docker\u8fdb\u884c\u5f00\u53d1\u7684\u6587\u7ae0\u7684\u7eed\u7bc7\u3002 Immutability\u548c\u6570\u636e \u6211\u5728\u4e0a\u8ff0\u6587\u7ae0\u4e2d\u63d0\u5230\u4e86\u8fdb\u884c\u5468 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5982\u4f55\u4f7f\u7528docker\u6765\u7ba1\u7406\u6570\u636e\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-03T11:16:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T16:33:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/4-0.png\" \/>\n<meta name=\"author\" content=\"\u5b87, \u534e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5b87, \u534e\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/\",\"name\":\"\u5982\u4f55\u4f7f\u7528Docker\u6765\u7ba1\u7406\u6570\u636e - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2022-11-03T11:16:35+00:00\",\"dateModified\":\"2024-04-29T16:33:41+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5982\u4f55\u4f7f\u7528Docker\u6765\u7ba1\u7406\u6570\u636e\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\",\"name\":\"\u5b87, \u534e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"caption\":\"\u5b87, \u534e\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u5982\u4f55\u4f7f\u7528Docker\u6765\u7ba1\u7406\u6570\u636e - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u5982\u4f55\u4f7f\u7528docker\u6765\u7ba1\u7406\u6570\u636e\/","og_locale":"zh_CN","og_type":"article","og_title":"\u5982\u4f55\u4f7f\u7528Docker\u6765\u7ba1\u7406\u6570\u636e","og_description":"\u203b \u8fd9\u662f\u5173\u4e8e\u4f7f\u7528Docker\u8fdb\u884c\u5f00\u53d1\u7684\u6587\u7ae0\u7684\u7eed\u7bc7\u3002 Immutability\u548c\u6570\u636e \u6211\u5728\u4e0a\u8ff0\u6587\u7ae0\u4e2d\u63d0\u5230\u4e86\u8fdb\u884c\u5468 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u5982\u4f55\u4f7f\u7528docker\u6765\u7ba1\u7406\u6570\u636e\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-11-03T11:16:35+00:00","article_modified_time":"2024-04-29T16:33:41+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d92a2913a08637a6e3848\/4-0.png"}],"author":"\u5b87, \u534e","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5b87, \u534e","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/","name":"\u5982\u4f55\u4f7f\u7528Docker\u6765\u7ba1\u7406\u6570\u636e - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2022-11-03T11:16:35+00:00","dateModified":"2024-04-29T16:33:41+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u5982\u4f55\u4f7f\u7528Docker\u6765\u7ba1\u7406\u6570\u636e"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458","name":"\u5b87, \u534e","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","caption":"\u5b87, \u534e"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8docker%e6%9d%a5%e7%ae%a1%e7%90%86%e6%95%b0%e6%8d%ae\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/50572","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=50572"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/50572\/revisions"}],"predecessor-version":[{"id":88597,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/50572\/revisions\/88597"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=50572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=50572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=50572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}