{"id":92,"date":"2021-09-10T14:42:44","date_gmt":"2021-09-10T06:42:44","guid":{"rendered":"http:\/\/139.155.46.233\/?p=92"},"modified":"2021-09-10T14:42:44","modified_gmt":"2021-09-10T06:42:44","slug":"%e6%90%ad%e5%bb%ba-docker","status":"publish","type":"post","link":"https:\/\/www.lucas88.cn\/?p=92","title":{"rendered":"\u642d\u5efa Docker"},"content":{"rendered":"\n<p>\u64cd\u4f5c\u7cfb\u7edf\uff1aCentOS 7.6 <\/p>\n\n\n\n<p>\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/docs.docker.com\/\" target=\"_blank\">Docker \u5b98\u65b9\u6587\u6863<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\".E5.89.8D.E6.8F.90.E6.9D.A1.E4.BB.B6\">\u524d\u63d0\u6761\u4ef6<\/h2>\n\n\n\n<p>\u5df2\u8d2d\u4e70 Linux \u4e91\u670d\u52a1\u5668\u3002\u5982\u679c\u60a8\u8fd8\u672a\u8d2d\u4e70\u4e91\u670d\u52a1\u5668\uff0c\u8bf7\u53c2\u8003&nbsp;<a href=\"https:\/\/cloud.tencent.com\/document\/product\/213\/2936\" target=\"_blank\" rel=\"noreferrer noopener\">\u5feb\u901f\u914d\u7f6e Linux \u4e91\u670d\u52a1\u5668<\/a>\u3002\u8bf4\u660e\uff1a<\/p>\n\n\n\n<p>\u642d\u5efa Docker \u5fc5\u987b\u4f7f\u752864\u4f4d\u7cfb\u7edf\uff0c\u4e14\u5185\u6838\u7248\u672c\u81f3\u5c11\u4e3a3.10\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\".E6.93.8D.E4.BD.9C.E6.AD.A5.E9.AA.A4\">\u64cd\u4f5c\u6b65\u9aa4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\".E5.AE.89.E8.A3.85-docker\">\u5b89\u88c5 Docker<\/h3>\n\n\n\n<p>1\u3001<a rel=\"noreferrer noopener\" href=\"https:\/\/cloud.tencent.com\/document\/product\/213\/5436\" target=\"_blank\">\u4f7f\u7528\u6807\u51c6\u65b9\u5f0f\u767b\u5f55 Linux \u5b9e\u4f8b\uff08\u63a8\u8350\uff09<\/a>\u3002\u60a8\u4e5f\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u64cd\u4f5c\u4e60\u60ef\uff0c\u9009\u62e9\u5176\u4ed6\u4e0d\u540c\u7684\u767b\u5f55\u65b9\u5f0f\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-center\"><a rel=\"noreferrer noopener\" href=\"https:\/\/cloud.tencent.com\/document\/product\/213\/35699\" target=\"_blank\">\u4f7f\u7528\u8fdc\u7a0b\u767b\u5f55\u8f6f\u4ef6\u767b\u5f55 Linux \u5b9e\u4f8b<\/a><\/p>\n\n\n\n<p class=\"has-text-align-center\"><a rel=\"noreferrer noopener\" href=\"https:\/\/cloud.tencent.com\/document\/product\/213\/35700\" target=\"_blank\">\u4f7f\u7528 SSH \u767b\u5f55 Linux \u5b9e\u4f8b<\/a><\/p>\n\n\n\n<p>2\u3001\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u6dfb\u52a0 yum \u6e90\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nyum update\nyum install epel-release -y\nyum clean all\nyum list\n<\/pre><\/div>\n\n\n<p>3\u3001\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5b89\u88c5 Docker\u3002<a href=\"javascript: void 0;\"><\/a><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nyum install docker-io -y\n<\/pre><\/div>\n\n\n<p>4\u3001\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u8fd0\u884c Docker\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nsystemctl start docker\n<\/pre><\/div>\n\n\n<p>5\u3001\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u68c0\u67e5\u5b89\u88c5\u7ed3\u679c\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\ndocker info\n<\/pre><\/div>\n\n\n<p>\u8fd4\u56de\u5982\u4e0b\u4fe1\u606f\uff0c\u5373\u8868\u793a\u5b89\u88c5\u6210\u529f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/139.155.46.233\/wp-content\/uploads\/2021\/09\/a848737e9d011f528f66dc54fca61c08.png\" alt=\"\" class=\"wp-image-93\" width=\"936\" height=\"319\" srcset=\"https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/09\/a848737e9d011f528f66dc54fca61c08.png 902w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/09\/a848737e9d011f528f66dc54fca61c08-300x102.png 300w, https:\/\/www.lucas88.cn\/wp-content\/uploads\/2021\/09\/a848737e9d011f528f66dc54fca61c08-768x262.png 768w\" sizes=\"auto, (max-width: 936px) 100vw, 936px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><span class=\"has-inline-color has-black-color\">\u4f7f\u7528 Docker<\/span><\/strong><\/h2>\n\n\n\n<p>Docker \u7684\u57fa\u672c\u4f7f\u7528\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7ba1\u7406 Docker \u5b88\u62a4\u8fdb\u7a0b\u3002<ul><li>\u8fd0\u884c Docker \u5b88\u62a4\u8fdb\u7a0b\uff1a<\/li><\/ul><\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nsystemctl start docker\n<\/pre><\/div>\n\n\n<p>\u505c\u6b62 Docker \u5b88\u62a4\u8fdb\u7a0b\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nsystemctl stop docker\n<\/pre><\/div>\n\n\n<p>\u91cd\u542f Docker \u5b88\u62a4\u8fdb\u7a0b\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nsystemctl restart docker\n<\/pre><\/div>\n\n\n<p>\u7ba1\u7406\u955c\u50cf\u3002\u672c\u6587\u4ee5 Docker Hub \u7684 Nginx \u955c\u50cf\u4e3a\u4f8b\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\ndocker pull nginx \n<\/pre><\/div>\n\n\n<p>\u4fee\u6539\u6807\u7b7e\uff1a\u60a8\u53ef\u4ee5\u4fee\u6539\u955c\u50cf\u6807\u7b7e\u4ee5\u4fbf\u8bb0\u5fc6\u533a\u5206\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\ndocker tag docker.io\/nginx:latest tencentyun\/nginx:v1\n<\/pre><\/div>\n\n\n<p>\u67e5\u770b\u5df2\u6709\u955c\u50cf\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\ndocker images\n<\/pre><\/div>\n\n\n<p>\u5f3a\u5236\u5220\u9664\u955c\u50cf\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\ndocker rmi -f tencentyun\/nginx:v1\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">\u5236\u4f5c\u955c\u50cf<\/h2>\n\n\n\n<p>1\u3001\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u6253\u5f00 Dockerfile \u6587\u4ef6\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nvim Dockerfile\n<\/pre><\/div>\n\n\n<p>2\u3001\u6309\u00a0<strong>i<\/strong>\u00a0\u5207\u6362\u81f3\u7f16\u8f91\u6a21\u5f0f\uff0c\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\nFROM tencentyun\/nginx:v2  #\u58f0\u660e\u57fa\u7840\u955c\u50cf\u6765\u6e90\u3002\nMAINTAINER DTSTACK #\u58f0\u660e\u955c\u50cf\u62e5\u6709\u8005\u3002\nRUN mkdir \/dtstact # RUN \u540e\u9762\u63a5\u5bb9\u5668\u8fd0\u884c\u524d\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4\uff0c\u7531\u4e8e Dockerfile \u6587\u4ef6\u4e0d\u80fd\u8d85\u8fc7127\u884c\uff0c\u56e0\u6b64\u5f53\u547d\u4ee4\u8f83\u591a\u65f6\u5efa\u8bae\u5199\u5230\u811a\u672c\u4e2d\u6267\u884c\u3002\nENTRYPOINT ping https:\/\/cloud.tencent.com\/ #\u5f00\u673a\u542f\u52a8\u547d\u4ee4\uff0c\u6b64\u5904\u6700\u540e\u4e00\u4e2a\u547d\u4ee4\u9700\u8981\u662f\u53ef\u5728\u524d\u53f0\u6301\u7eed\u6267\u884c\u7684\u547d\u4ee4\uff0c\u5426\u5219\u5bb9\u5668\u540e\u53f0\u8fd0\u884c\u65f6\u4f1a\u56e0\u4e3a\u547d\u4ee4\u6267\u884c\u5b8c\u800c\u9000\u51fa\u3002\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\"><li>3\u3001\u6309\u00a0<strong>Esc<\/strong>\uff0c\u8f93\u5165\u00a0<strong>:wq<\/strong>\uff0c\u4fdd\u5b58\u6587\u4ef6\u5e76\u8fd4\u56de\u3002<\/li><li>4\u3001\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u6784\u5efa\u955c\u50cf\u3002<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\ndocker build -t nginxos:v1 .  #.\u662f Dockerfile \u6587\u4ef6\u7684\u8def\u5f84\uff0c\u4e0d\u80fd\u5ffd\u7565\u3002\n<\/pre><\/div>\n\n\n<p>5\u3001\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770b\u955c\u50cf\u662f\u5426\u521b\u5efa\u6210\u529f\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\ndocker images\n<\/pre><\/div>\n\n\n<p>6\u3001\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u8fd0\u884c\u5bb9\u5668\u5e76\u67e5\u770b\u5bb9\u5668\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\ndocker run -d nginxos:v1         #\u540e\u53f0\u8fd0\u884c\u5bb9\u5668\u3002\ndocker ps                        #\u67e5\u770b\u5f53\u524d\u8fd0\u884c\u4e2d\u7684\u5bb9\u5668\u3002\ndocker ps -a                     #\u67e5\u770b\u6240\u6709\u5bb9\u5668\uff0c\u5305\u62ec\u672a\u8fd0\u884c\u4e2d\u7684\u3002\ndocker logs CONTAINER ID\/IMAGE   #\u5982\u672a\u67e5\u770b\u5230\u521a\u624d\u8fd0\u884c\u7684\u5bb9\u5668\uff0c\u5219\u7528\u5bb9\u5668 ID \u6216\u8005\u540d\u5b57\u67e5\u770b\u542f\u52a8\u65e5\u5fd7\u6392\u9519\u3002\n<\/pre><\/div>\n\n\n<p>7\u3001\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5236\u4f5c\u955c\u50cf\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\ndocker commit fb2844b6**** nginxweb:v2 #commit \u53c2\u6570\u540e\u6dfb\u52a0\u5bb9\u5668 ID \u548c\u6784\u5efa\u65b0\u955c\u50cf\u7684\u540d\u79f0\u548c\u7248\u672c\u53f7\u3002\ndocker images                    #\u5217\u51fa\u672c\u5730\uff08\u5df2\u4e0b\u8f7d\u7684\u548c\u672c\u5730\u521b\u5efa\u7684\uff09\u955c\u50cf\u3002\n<\/pre><\/div>\n\n\n<p>8\u3001\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u955c\u50cf\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93\u3002<br>\u9ed8\u8ba4\u63a8\u9001\u5230 Docker Hub\u3002\u60a8\u9700\u8981\u5148\u767b\u5f55 Docker\uff0c\u4e3a\u955c\u50cf\u7ed1\u5b9a\u6807\u7b7e\uff0c\u5c06\u955c\u50cf\u547d\u540d\u4e3a\u00a0<code>Docker \u7528\u6237\u540d\/\u955c\u50cf\u540d:\u6807\u7b7e<\/code>\u7684\u683c\u5f0f\uff0c\u6700\u7ec8\u5b8c\u6210\u63a8\u9001\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ==============Code==============; notranslate\" title=\"==============Code==============\">\ndocker login #\u6267\u884c\u540e\u8f93\u5165\u955c\u50cf\u4ed3\u5e93\u7528\u6237\u540d\u53ca\u5bc6\u7801\ndocker tag &#x5B;\u955c\u50cf\u540d]:&#x5B;\u6807\u7b7e] &#x5B;\u7528\u6237\u540d]:&#x5B;\u6807\u7b7e]\ndocker push &#x5B;\u7528\u6237\u540d]:&#x5B;\u6807\u7b7e]\n<\/pre><\/div>\n\n\n<p>\u63a8\u9001\u5b8c\u6210\u540e\uff0c\u5373\u53ef\u4f7f\u7528\u6d4f\u89c8\u5668\u767b\u5f55 Docker Hub \u5b98\u7f51\u8fdb\u884c\u67e5\u770b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u64cd\u4f5c\u7cfb\u7edf\uff1aCentOS 7.6 \u00a0Docker \u5b98\u65b9\u6587\u6863 \u524d\u63d0\u6761\u4ef6 \u5df2\u8d2d\u4e70 Linux \u4e91\u670d\u52a1\u5668\u3002\u5982\u679c\u60a8\u8fd8\u672a\u8d2d&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/www.lucas88.cn\/?p=92\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,2],"tags":[],"class_list":["post-92","post","type-post","status-publish","format-standard","hentry","category-linux","category-jsfx"],"_links":{"self":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/92","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=92"}],"version-history":[{"count":1,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/92\/revisions"}],"predecessor-version":[{"id":94,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=\/wp\/v2\/posts\/92\/revisions\/94"}],"wp:attachment":[{"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lucas88.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}