{"id":11968,"date":"2019-01-29T22:08:46","date_gmt":"2019-01-29T14:08:46","guid":{"rendered":"http:\/\/yidianhulian.com\/?p=11968"},"modified":"2020-10-18T22:09:51","modified_gmt":"2020-10-18T14:09:51","slug":"docker%e9%85%8d%e7%bd%aelamp%e7%8e%af%e5%a2%83%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/yidianhulian.com\/?p=11968","title":{"rendered":"docker\u914d\u7f6elamp\u73af\u5883\u7b14\u8bb0"},"content":{"rendered":"\n<p><strong>\u57fa\u672c\u6982\u5ff5<\/strong><\/p>\n\n\n\n<p>\u5bb9\u5668container\u672c\u8d28\u662f\u4e00\u4e2a\u8fd0\u884c\u5728\u4e3b\u673a\u4e0a\u7684\u8fdb\u7a0b<\/p>\n\n\n\n<ul><li>\u67e5\u770b\u8fd0\u884c\u7684\u5bb9\u5668docker ps \u9ed8\u8ba4\u53ea\u770b\u8fd0\u884c\u4e2d\u7684<\/li><li>\u67e5\u770b\u6240\u6709\u7684\u5bb9\u5668docker ps -a<\/li><li>\u5220\u9664\u5bb9\u5668 docker rm \u5bb9\u5668id[\u6216\u5bb9\u5668\u540d]<\/li><li>\u505c\u6b62\u4e00\u4e2a\u5bb9\u5668 docker stop \u5bb9\u5668id<\/li><\/ul>\n\n\n\n<p>\u955c\u50cfimage\u662f\u5bb9\u5668\u7684\u9759\u6001\u6982\u5ff5\uff08\u53ef\u4ee5\u770b\u505a\u5bb9\u5668\u7684\u201c\u5b89\u88c5\u5305\u201d\uff09<\/p>\n\n\n\n<ul><li>\u67e5\u770b\u5b89\u88c5\u7684\u955c\u50cfdocker images<\/li><li>\u5220\u9664\u955c\u50cfdocker rmi \u955c\u50cf\u540d<\/li><\/ul>\n\n\n\n<p>\u4ed3\u5e93\u662f\u5b58\u653e\u955c\u50cf\u7684\u5730\u65b9\uff0c\u8ddfgit\u4e00\u6837\u7684<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/p3-tt.byteimg.com\/origin\/pgc-image\/9326d1b238434b37a5ab8ba267e38d4a?from=pc\" alt=\"docker\u914d\u7f6elamp\u73af\u5883\u7b14\u8bb0\"\/><\/figure>\n\n\n\n<p>\u955c\u50cf\u662f\u6253\u5305\u597d\u7684\u8fd0\u884c\u73af\u5883\uff0c\u6bd4\u5982centos\uff0c\u505a\u597d\u8fd9\u4e2a\u955c\u50cf\u540e\u4e0a\u4f20\u5230\u955c\u50cf\u5e93\uff0c\u522b\u4eba\u5c31\u53ef\u4ee5\u76f4\u63a5pull\u4e0b\u6765\u8fd0\u884c\u4f7f\u7528\u4e86\u3002<\/p>\n\n\n\n<p><strong>\u5b89\u88c5\u8fc7\u7a0b\u8bb0\u5f55<\/strong><\/p>\n\n\n\n<ol><li>\u62c9\u53d6\u955c\u50cf docker pull centos<\/li><li>\u8fd0\u884c\u5bb9\u5668 docker run -it -p 8080:80 centos \/bin\/bash \u8be5\u547d\u4ee4\u603b\u662f\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u5bb9\u5668\uff0c\u5982\u679c\u8981\u542f\u52a8\u5df2\u7ecf\u5b58\u5728\u7684\u5bb9\u5668\uff0c\u7528docker start \u5bb9\u5668id<\/li><li>-i \u4ea4\u4e92\u6a21\u5f0f<\/li><li>-t \u5206\u914d\u4e00\u4e2a\u4f2a\u7ec8\u7aef<\/li><li>-p \u4e3b\u673a\u7aef\u53e3:\u5bb9\u5668\u5185\u7684\u7aef\u53e3<\/li><li>centos\u955c\u50cf\u540d\uff0c\u516c\u5171\u53d7\u4fe1\u4efb\u7684\u955c\u50cf\u53ef\u4ee5\u76f4\u63a5\u7528\u955c\u50cf\u540d\uff0c\u4e2a\u4eba\u955c\u50cf\u4e00\u822c\u662f\u955c\u50cf\u5e93\u7528\u6237\u540d\/\u955c\u50cf\u540d\uff0c\u955c\u50cf\u5e93\u548cgit\u5e93\u7c7b\u4f3c\uff0c\u5982\u679c\u8981\u62c9\u53d6\u8fdb\u884c\u7684\u67d0\u4e2a\u7248\u672c\u6807\u7b7e\uff0c\u53ef\u4ee5\u955c\u50cf\u540d:[Tag\u540d]<\/li><li>\/bin\/bash\u542f\u52a8\u955c\u50cf\u540e\u6267\u884c\u7684\u547d\u4ee4\uff0c\u8fd9\u91cc\u4e5f\u5c31\u662f\u542f\u52a8\u540e\u6253\u5f00\u7ec8\u7aef\uff0c\u7136\u540e\u53ef\u4ee5\u4f7f\u7528centos\u7684yum\u5b89\u88c5\u9700\u8981\u7684\u5305\uff0csystemctl start \u542f\u52a8\u9700\u8981\u7684\u670d\u52a1<\/li><li>\u4f46\u5728systemctl start\u65f6\u62a5\u9519\uff1aFailed to get D-Bus connection: Operation not permitted<\/li><li>\u8fd9\u662f\u56e0\u4e3aD-Bus\u6ca1\u6709\u542f\u52a8\uff0c\u542f\u52a8\u9009\u9879\u52a0\u4e0a &#8211;privileged -d\uff0c\u5e76\u628a\u547d\u4ee4\u4ece\/bin\/bash \u4fee\u6539\u4e3ainit<\/li><li>init\u5c31\u662f\/usr\/sbin\/init\uff0c \u91cc\u9762\u4f1a\u81ea\u52a8\u542f\u52a8D-Bus<\/li><li>&#8211;privileged \u8d4b\u4e88\u5bb9\u5668\u66f4\u591a\u7684\u6743\u9650\uff0c\u4ee5\u4fbf\u6b63\u5e38\u542f\u52a8D-Bus<\/li><li>-d\u662f\u8fdb\u5165\u540e\u53f0\u8fd0\u884c\uff0cinit\u5e76\u4e0d\u662f\u63a7\u5236\u7ec8\u7aef\uff0c\u6267\u884c\u5b8c\u6210\u540e\u5b83\u4f1a\u4e00\u76f4\u505c\u5728\u90a3\u4e2a\u5730\u65b9\uff0c\u65e0\u6cd5\u8fdb\u884c\u547d\u4ee4\u4ea4\u4e92\uff0c\u6240\u4ee5-d\u8ba9\u4ed6\u8131\u79bb\u547d\u4ee4\u884c\uff0c\u8fdb\u5165\u540e\u53f0\u8fd0\u884c<\/li><li>\u7136\u540edocker exec -it [\u5bb9\u5668id] \/bin\/bash \u8fdb\u5165\u5bb9\u5668\u7684\u7ec8\u7aef\uff0c\u63a5\u7740\u5c31\u53ef\u4ee5\u8fdb\u884c\u4f7f\u7528centos\u7684\u5404\u9879\u547d\u4ee4\u4e86<\/li><li>\u9700\u8981\u5b89\u88c5\u7684\u5185\u5bb9<\/li><li>PHP<\/li><li>Apache<\/li><li>MySQL<\/li><li>openssh-server \u65b9\u4fbf\u901a\u8fc7ssh\u767b\u5f55\u5bb9\u5668\uff0c\u4e3b\u8981\u662f\u65b9\u4fbf\u7528sftp scp\u8fd9\u4e9b\u4e0a\u4f20\u4e0b\u8f7d\u4ee3\u7801<\/li><li>\u76ee\u5f55\u5171\u4eab\uff0c\u6211\u4eec\u53ef\u4ee5\u628adocker\u5bb9\u5668\u4e2dapache\u7684\u5de5\u4f5c\u76ee\u5f55\u6302\u8f7d\u5230\u4e3b\u673a\u4e0a\uff08\u8fd0\u884cdocker\u7684\u673a\u5668\uff09\u7684\u76ee\u5f55<\/li><li>\u589e\u52a0ssh\u7aef\u53e3\u6620\u5c04\uff0c\u5982\u679crun\u540e\u53d1\u73b0\u9700\u8981\u589e\u52a0\u7aef\u53e3, \u6bd4\u5982\u589e\u52a0ssh\u7aef\u53e3\uff0c\u53ef\u4ee5\u8fd9\u4e48\u505a<\/li><li>docker commit [\u5bb9\u5668id] [\u8d77\u4e00\u4e2a\u540d\u5b57]\uff0c\u5148\u628a\u5f53\u524d\u7684\u5bb9\u5668\u53e6\u5b58\u4e3a\u4e00\u4e2a\u955c\u50cf<\/li><li>\u7136\u540e\u5728\u7528run\u542f\u52a8\u8fd9\u4e2a\u955c\u50cf\uff0c\u5e76\u5e26\u4e0a\u4f60\u6dfb\u52a0\u7684\u7aef\u53e3 docker run -it -p 2222:22 -p 8080:80 &#8211;privileged -d [commit\u65f6\u7684\u955c\u50cf\u540d\u5b57] init<\/li><li>\u4f46\u8fd9\u91cc\u8981\u6ce8\u610f\uff0c\u4e4b\u524d\u7684\u7aef\u53e3\u6620\u5c04\u4e5f\u8981\u52a0\u4e0a , \u8fd9\u91cc\u7684\u505a\u6cd5\u53ea\u662f\u5728\u4e4b\u524d\u7684\u5bb9\u5668\u4e0a\u7ee7\u7eed\u542f\u52a8\uff0c\u4e4b\u524d\u955c\u50cf\u4e2d\u5b89\u88c5\u7684\u5185\u5bb9\u4e5f\u8fd8\u5728\uff0c\u4f46run\u547d\u4ee4\u7684\u53c2\u6570\u548c\u4e4b\u524d\u662f\u4e00\u6837\u7684\uff0c\u589e\u52a0\u5185\u5bb9\u800c\u5df2<\/li><li>vim \/etc\/ssh\/sshd_config<\/li><li>\u6dfb\u52a0PermitRootLogin yes<\/li><li>\u8bb0\u5f97docker exec -it [\u5bb9\u5668id] \/bin\/bash\u540e\u8bbe\u7f6e\u4e00\u4e2aroot\u5bc6\u7801<\/li><li>\u5728\u4e0a\u9762\u4e3b\u673a\u548c\u5bb9\u5668\u76ee\u5f55\u5171\u4eab\uff0c\u5728run\u65f6\u52a0\u4e0a\u53c2\u6570 -v [\u4e3b\u673a\u7684\u76ee\u5f55]:[\u5bb9\u5668\u4e2d\u7684\u76ee\u5f55]\uff0c\u6bd4\u5982 -v \/workspace\/ydeditor:\/var\/www\/html<\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u672c\u6982\u5ff5 \u5bb9\u5668container\u672c\u8d28\u662f\u4e00\u4e2a\u8fd0\u884c\u5728\u4e3b\u673a\u4e0a\u7684\u8fdb\u7a0b \u67e5\u770b\u8fd0\u884c\u7684\u5bb9\u5668docker ps \u9ed8\u8ba4\u53ea\u770b\u8fd0\u884c\u4e2d &hellip; <a href=\"https:\/\/yidianhulian.com\/?p=11968\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">docker\u914d\u7f6elamp\u73af\u5883\u7b14\u8bb0<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_links_to":"","_links_to_target":""},"categories":[148],"tags":[149,150,96],"_links":{"self":[{"href":"https:\/\/yidianhulian.com\/index.php?rest_route=\/wp\/v2\/posts\/11968"}],"collection":[{"href":"https:\/\/yidianhulian.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yidianhulian.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yidianhulian.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yidianhulian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11968"}],"version-history":[{"count":1,"href":"https:\/\/yidianhulian.com\/index.php?rest_route=\/wp\/v2\/posts\/11968\/revisions"}],"predecessor-version":[{"id":11969,"href":"https:\/\/yidianhulian.com\/index.php?rest_route=\/wp\/v2\/posts\/11968\/revisions\/11969"}],"wp:attachment":[{"href":"https:\/\/yidianhulian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yidianhulian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yidianhulian.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}