{"id":375,"date":"2021-04-08T10:08:32","date_gmt":"2021-04-08T10:08:32","guid":{"rendered":"http:\/\/robinluo.top\/?p=375"},"modified":"2021-04-08T16:13:46","modified_gmt":"2021-04-08T16:13:46","slug":"docker%e5%85%a5%e9%97%a8","status":"publish","type":"post","link":"https:\/\/robinluo.top\/?p=375","title":{"rendered":"docker\u5165\u95e8"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1354\" height=\"1208\" src=\"http:\/\/robinluo.top\/wp-content\/uploads\/2021\/04\/f703738da977391281957edbf0198618377ae2dd.png\" alt=\"\" class=\"wp-image-376\"\/><\/figure>\n\n\n\n<p>docker \u662f\u5bb9\u5668\u5316\u670d\u52a1\u7684\u5b9e\u73b0<\/p>\n\n\n\n<p>docker \u5206\u4e3a\u4e09\u90e8\u5206 \u955c\u50cf  \u672c\u5730\u673a\u5668   \u548c  \u955c\u50cf\u670d\u52a1\u4e2d\u5fc3<\/p>\n\n\n\n<p>\u672c\u5730\u4ece\u955c\u50cf\u670d\u52a1\u4e2d\u5fc3\u62bd\u53d6\u955c\u50cf\u5230\u672c\u5730 \uff0c \u672c\u5730docker\u670d\u52a1\u4f1a\u7ef4\u6301\u7740\u4e00\u4e2a\u955c\u50cf\u7ba1\u7406\u670d\u52a1\u3002\u5f53\u8fd0\u884c\u671f\u5bf9\u5e94\u7684\u955c\u50cf\uff0c\u5c31\u80fd\u4ee5\u5bb9\u5668\u5316\u65b9\u5f0f\u542f\u52a8\u5bf9\u5e94\u7684\u670d\u52a1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker search nginx\n\u5411\u955c\u50cf\u4e2d\u5fc3\u641c\u7d22nginx\u7684\u955c\u50cf\n\ndocker pull httpd\n\u5411\u955c\u50cf\u4e2d\u5fc3\u4e0b\u8f7dhttpd\u955c\u50cf\u5230\u672c\u5730\n\ndocker images\n\u5217\u51fa\u672c\u673a\u4e0b\u8f7d\u4e86\u7684\u955c\u50cf\u5217\u8868\n\ndocker rmi \u955c\u50cfid\/name\n\u5220\u9664\u4e0b\u8f7d\u5230\u672c\u5730\u7684\u955c\u50cf i\u6307\u7684\u662fimage\n\ndocker run -d -p80:80 nginx\n\u4ee5daemon\u65b9\u5f0f\u8fd0\u884cnginx\u955c\u50cf \u5e76 \u6307\u5b9a\u5bb9\u5668\u768480 \u6620\u5c04\u5230\u672c\u673a\u768480\u7aef\u53e3\n\ndocker run -d -p8080:80 --name apache httpd\n\u4ee5daemon\u65b9\u5f0f\u542f\u52a8httpd\u955c\u50cf \u5e76 \u6307\u5b9a\u5bb9\u566880 \u6620\u5c04\u5230\u672c\u5730\u76848080\u7aef\u53e3 \u4e14\u8d77\u540d\u4e3aapache\n\ndocket run -d -p8080:80 --name apache httpd --volumes\/(-v) .\/app:\/var\/www\/html\/\n\u5c06\u672c\u5730\u7684.\/app \u6620\u5c04\u5230 \u670d\u52a1\u7684 \/var\/www\/html\n\ndocker start apache\n\u542f\u52a8\u6307\u5b9a\u7684\u955c\u50cf\u670d\u52a1\n\ndocker stop apache \n\u4ee5\u8fd0\u884c\u65f6\u6307\u5b9a\u7684name \u505c\u6b62 \u6307\u5b9a\u5bb9\u5668\u670d\u52a1\n\ndocker stop 562jggs92h4ff\n\u4ee5\u5bb9\u5668id \u505c\u6b62\u5bb9\u5668\u670d\u52a1\n\ndocker ps\n\u5217\u51fa\u5f53\u524d\u8fd0\u884c\u4e2d\u7684\u5bb9\u5668\u670d\u52a1 \uff08\u4f1a\u663e\u793a\u5bb9\u5668id \u7aef\u53e3\u6620\u5c04  \u548c\u522b\u540d\uff09\n\ndocker ps -a \n\u5217\u51fa\u6240\u6709\u672c\u673a\u7684\u5bb9\u5668\u670d\u52a1 \uff08\u5305\u62ec\u505c\u6b62\u4e86\u7684\uff09\n\ndocker rm \u5bb9\u5668ID\/name\n\u5220\u9664\u672c\u673a\u5bb9\u5668\u670d\u52a1\n\n\ndocker exec -it  CONTAINER_ID\/name  \/bin\/sh\n\u8fdb\u5165\u67d0\u4e2a\u5bb9\u5668 \u5e76\u4e14 i \u4ee3\u8868interactive\u4ea4\u4e92\u5f0f \u8f93\u5165\u6d41 \u548c\u8f93\u51fa\u6d41 \u5728\u5f53\u524dshell\u4ea4\u4e92\nt \u4ee3\u8868 tty \u4ee3\u8868\u5bb9\u5668\u5185\u4e00\u4e2a\u7ec8\u7aef \/bin\/sh \u6267\u884c\u67d0\u4e2a\u547d\u4ee4 \u5373\u8fdb\u5165shell\u6a21\u5f0f\n\n\n\u5176\u4ed6\ndocker help CMD \u67e5\u770b\u67d0\u4e2a\u547d\u4ee4\n\ndocker inspect XXX\n\u67e5\u770b\u67d0\u4e2a\u670d\u52a1\u7684\u6240\u6709\u60c5\u51b5  \u5305\u62ec\u786c\u76d8\u6587\u4ef6\u5939\u6302\u8f7d\u4fe1\u606f\n\ndocker log -f XXX\n\u4e00\u76f4\u8ddf\u8e2a\u5e76\u67e5\u770b\u670d\u52a1\u65e5\u5fd7\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>docker \u662f\u5bb9\u5668\u5316\u670d\u52a1\u7684\u5b9e\u73b0 docker \u5206\u4e3a\u4e09\u90e8\u5206 \u955c\u50cf \u672c\u5730\u673a\u5668 \u548c \u955c\u50cf\u670d\u52a1\u4e2d\u5fc3 \u672c\u5730\u4ece\u955c\u50cf\u670d\u52a1\u4e2d\u5fc3\u62bd\u53d6\u955c\u50cf\u5230\u672c\u5730 \uff0c \u672c\u5730docker\u670d\u52a1\u4f1a\u7ef4\u6301\u7740\u4e00\u4e2a\u955c\u50cf\u7ba1\u7406\u670d\u52a1\u3002\u5f53\u8fd0\u884c\u671f\u5bf9\u5e94\u7684\u955c\u50cf\uff0c\u5c31\u80fd\u4ee5\u5bb9\u5668\u5316\u65b9\u5f0f\u542f\u52a8\u5bf9\u5e94\u7684\u670d\u52a1\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[60],"tags":[],"_links":{"self":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/375"}],"collection":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=375"}],"version-history":[{"count":8,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/375\/revisions"}],"predecessor-version":[{"id":387,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/375\/revisions\/387"}],"wp:attachment":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}