{"id":504,"date":"2021-09-27T01:43:00","date_gmt":"2021-09-27T01:43:00","guid":{"rendered":"https:\/\/262235.xyz\/?p=504"},"modified":"2021-09-27T01:43:00","modified_gmt":"2021-09-27T01:43:00","slug":"504","status":"publish","type":"post","link":"https:\/\/lyvba.com\/index.php\/2021\/09\/27\/504\/","title":{"rendered":"Docker\u5b66\u4e60\u89c6\u9891\u5efa\u7acb\u81ea\u5b9a\u4e49\u955c\u50cf: commit  \u6839\u636e\u5bb9\u5668\u7684\u66f4\u6539\u521b\u5efa\u65b0\u56fe\u50cf"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/lyvba.com\/wp-content\/uploads\/2021\/09\/3417355026.jpg\" alt=\"3351771764.jpg\" title=\"3351771764.jpg\"><\/p>\n<h2><code>docker commit<\/code> \u6839\u636e\u5bb9\u5668\u7684\u66f4\u6539\u521b\u5efa\u65b0\u56fe\u50cf<\/h2>\n<p>\u5c06\u5bb9\u5668\u7684\u6587\u4ef6\u66f4\u6539\u6216\u8bbe\u7f6e\u63d0\u4ea4\u5230\u65b0\u6620\u50cf\u4e2d\u53ef\u80fd\u5f88\u6709\u7528\u3002\u8fd9\u4f7f\u60a8\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ea4\u4e92\u5f0f\u5916\u58f3\u7a0b\u5e8f\u6765\u8c03\u8bd5\u5bb9\u5668\uff0c\u6216\u5c06\u5de5\u4f5c\u6570\u636e\u96c6\u5bfc\u51fa\u5230\u53e6\u4e00\u53f0\u670d\u52a1\u5668\u3002\u901a\u5e38\uff0c\u6700\u597d\u4f7f\u7528Dockerfiles\u4ee5\u6587\u6863\u5316\u548c\u53ef\u7ef4\u62a4\u7684\u65b9\u5f0f\u6765\u7ba1\u7406\u6620\u50cf\u3002<\/p>\n<ul>\n<li>Docker \u76f8\u5173\u6587\u7ae0<\/li>\n<li><a href=\"https:\/\/www.lyvba.com\/index.php\/tag\/docker\/\">https:\/\/www.lyvba.com\/index.php\/tag\/docker\/<\/a><\/li>\n<\/ul>\n<h2>\u4f8b\u5b50 <code>commit<\/code> \u63d0\u4ea4\u5bb9\u5668<\/h2>\n<pre><code>$  docker ps -a\nCONTAINER ID   IMAGE         COMMAND    CREATED              STATUS                          PORTS     NAMES\nba21356c8dea   debian        \"bash\"     About a minute ago   Exited (0) 15 seconds ago                 peaceful_sammet\n\n$  docker commit ba21356c8dea  myphp\nsha256:b795a0199077c8b48ff48193dee3268b517df99cdd258dc49a6929694b6ce57b\n\n$  docker images\nREPOSITORY    TAG       IMAGE ID       CREATED          SIZE\nmyphp         latest    b795a0199077   15 seconds ago   271MB\ndebian        latest    82bd5ee7b1c5   3 weeks ago      124MB<\/code><\/pre>\n<h2>\u67e5\u770b\u955c\u50cf\u5386\u53f2<\/h2>\n<pre><code>$  docker history myphp\nIMAGE          CREATED          CREATED BY                                      SIZE      COMMENT\nb795a0199077   25 seconds ago   bash                                            147MB\n82bd5ee7b1c5   3 weeks ago      \/bin\/sh -c #(nop)  CMD [\"bash\"]                 0B\n&lt;missing&gt;      3 weeks ago      \/bin\/sh -c #(nop) ADD file:1fedf68870782f1b4\u2026   124MB    <\/code><\/pre>\n<h2>\u4f7f\u7528myphp\u955c\u50cf\u5efa\u7acb\u5bb9\u5668<\/h2>\n<pre><code>$  docker run -itd myphp bash\n46b98f18d17249674b7cdebd1161a65285aaafb94f193cd7ab76294571334224\n\n$  docker ps\nCONTAINER ID   IMAGE     COMMAND   CREATED          STATUS          PORTS     NAMES\n46b98f18d172   myphp     \"bash\"    16 seconds ago   Up 14 seconds             zealous_mirzakhani\n\n$  docker exec  -it 46b98f18d172 php -v\nPHP 7.4.21 (cli) (built: Jul  2 2021 03:59:48) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies\n\n$  docker exec  -it 46b98f18d172  bash <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>docker commit \u6839\u636e\u5bb9\u5668\u7684\u66f4\u6539\u521b\u5efa\u65b0\u56fe\u50cf \u5c06\u5bb9\u5668\u7684\u6587\u4ef6\u66f4\u6539\u6216\u8bbe\u7f6e\u63d0\u4ea4\u5230\u65b0\u6620\u50cf\u4e2d\u53ef\u80fd\u5f88\u6709\u7528 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[15],"class_list":["post-504","post","type-post","status-publish","format-standard","hentry","category-docker","tag-docker"],"_links":{"self":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/comments?post=504"}],"version-history":[{"count":0,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/504\/revisions"}],"wp:attachment":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/media?parent=504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/categories?post=504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/tags?post=504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}