{"id":998,"date":"2024-10-09T16:59:23","date_gmt":"2024-10-09T08:59:23","guid":{"rendered":"https:\/\/www.coffecat.cn\/?p=998"},"modified":"2024-10-09T16:59:23","modified_gmt":"2024-10-09T08:59:23","slug":"%e9%a1%b9%e7%9b%ae%e5%ae%9e%e6%88%98%e8%ae%b0%e5%bd%95-%e3%80%90%e7%94%a8%e6%88%b7%e4%b8%ad%e5%bf%83%e9%a1%b9%e7%9b%ae%e3%80%91%e7%94%a8%e6%88%b7%e4%b8%ad%e5%bf%83%e9%a1%b9%e7%9b%ae%e4%b8%8a%e7%ba%bf","status":"publish","type":"post","link":"https:\/\/www.coffecat.cn\/index.php\/2024\/10\/09\/%e9%a1%b9%e7%9b%ae%e5%ae%9e%e6%88%98%e8%ae%b0%e5%bd%95-%e3%80%90%e7%94%a8%e6%88%b7%e4%b8%ad%e5%bf%83%e9%a1%b9%e7%9b%ae%e3%80%91%e7%94%a8%e6%88%b7%e4%b8%ad%e5%bf%83%e9%a1%b9%e7%9b%ae%e4%b8%8a%e7%ba%bf\/","title":{"rendered":"\u9879\u76ee\u5b9e\u6218\u8bb0\u5f55 -\u3010\u7528\u6237\u4e2d\u5fc3\u9879\u76ee\u3011\u7528\u6237\u4e2d\u5fc3\u9879\u76ee\u4e0a\u7ebf\u90e8\u7f72"},"content":{"rendered":"\n<p>\u7531\u4e8e\u6211\u662f\u4f7f\u7528\u7684\u81ea\u5e26\u5b9d\u5854\u7684Linux\u6240\u4ee5\u6211\u8fd9\u91cc\u4f7f\u7528\u7684\u90e8\u7f72\u65b9\u5f0f\u662f\u5728\u670d\u52a1\u5668\u4e2d\u90e8\u7f72\u4ee5\u53ca\u5728docker\u5bb9\u5668\u4e2d\u90e8\u7f72\uff0c\u4e4b\u524d\u5728\u9879\u76ee\u4e0a\u7684\u5821\u5792\u673a\u662fwinserver\uff0c\u540e\u7aef\u90e8\u7f72\u51c6\u5907\u4e00\u4e2a\u811a\u672c\u6587\u4ef6\uff0c\u524d\u7aef\u5c31\u4e0b\u8f7d\u4e00\u4e2anginx\u6539\u4e0b\u914d\u7f6e\u6587\u4ef6\u628a\u5305\u4e22\u8fdb\u53bb\u542f\u52a8\u5c31\u53ef\u4ee5\u4e86<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Linux\u539f\u59cb\u90e8\u7f72<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# \u4e0b\u8f7d Nginx \u6e90\u7801\ncurl -o nginx-1.21.6.tar.gz http:\/\/nginx.org\/download\/nginx-1.21.6.tar.gz\n\n# \u89e3\u538b\u6e90\u7801\u5305\ntar -zxvf nginx-1.21.6.tar.gz\n\n# \u8fdb\u5165 Nginx \u6e90\u7801\u76ee\u5f55\ncd nginx-1.21.6\n\n# \u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56\u5305\nyum install pcre pcre-devel openssl openssl-devel -y\n\n# \u914d\u7f6e Nginx\n.\/configure --with-http_ssl_module --with-http_v2_module --with-stream\n\n# \u7f16\u8bd1 Nginx\nmake\n\n# \u5b89\u88c5 Nginx\nmake install\n\n# \u5c06 Nginx \u53ef\u6267\u884c\u6587\u4ef6\u8def\u5f84\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\necho 'export PATH=$PATH:\/usr\/local\/nginx\/sbin' &gt;&gt; \/etc\/profile\n\n# \u4f7f\u914d\u7f6e\u751f\u6548\nsource \/etc\/profile\n\n# \u542f\u52a8 Nginx\nnginx\n\n# \u67e5\u770b Nginx \u542f\u52a8\u60c5\u51b5\nnetstat -ntlp | grep nginx\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># \u4e0b\u8f7d Nginx \u6e90\u7801<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">curl<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-o<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">nginx-1.21.6.tar.gz<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">http:\/\/nginx.org\/download\/nginx-1.21.6.tar.gz<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u89e3\u538b\u6e90\u7801\u5305<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">tar<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-zxvf<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">nginx-1.21.6.tar.gz<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u8fdb\u5165 Nginx \u6e90\u7801\u76ee\u5f55<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">cd<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">nginx-1.21.6<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56\u5305<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">yum<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">install<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">pcre<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">pcre-devel<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">openssl<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">openssl-devel<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-y<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u914d\u7f6e Nginx<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">.\/configure<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">--with-http_ssl_module<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">--with-http_v2_module<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">--with-stream<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u7f16\u8bd1 Nginx<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">make<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u5b89\u88c5 Nginx<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">make<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">install<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u5c06 Nginx \u53ef\u6267\u884c\u6587\u4ef6\u8def\u5f84\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">echo<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">export PATH=$PATH:\/usr\/local\/nginx\/sbin<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">&gt;&gt;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">\/etc\/profile<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u4f7f\u914d\u7f6e\u751f\u6548<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">source<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">\/etc\/profile<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u542f\u52a8 Nginx<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">nginx<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u67e5\u770b Nginx \u542f\u52a8\u60c5\u51b5<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">netstat<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-ntlp<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">|<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">grep<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">nginx<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u540e\u7aef<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# \u5b89\u88c5 Java \u73af\u5883\nyum install -y java-1.8.0-openjdk*\n\n# \u4e0b\u8f7d\u5e76\u89e3\u538b Maven\ncurl -o apache-maven-3.8.5-bin.tar.gz https:\/\/dlcdn.apache.org\/maven\/maven-3\/3.8.5\/binaries\/apache-maven-3.8.5-bin.tar.gz\n# \u4e0b\u8f7d\u4ee3\u7801\ngit clone xxx \n\n# \u6253\u5305\u6784\u5efa\uff0c\u8df3\u8fc7\u6d4b\u8bd5\nmvn package -DskipTests\n\n# \u540e\u53f0\u542f\u52a8 Spring Boot \u5e94\u7528\nnohup java -jar .\/user-center-backend-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod &gt; \/dev\/null 2&gt;&amp;1 &amp;\n\n# \u67e5\u770b\u5e94\u7528\u542f\u52a8\u60c5\u51b5\nnetstat -ntlp | grep java\n\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># \u5b89\u88c5 Java \u73af\u5883<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">yum<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">install<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-y<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">java-1.8.0-openjdk<\/span><span style=\"color: #81A1C1\">*<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u4e0b\u8f7d\u5e76\u89e3\u538b Maven<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">curl<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-o<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">apache-maven-3.8.5-bin.tar.gz<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">https:\/\/dlcdn.apache.org\/maven\/maven-3\/3.8.5\/binaries\/apache-maven-3.8.5-bin.tar.gz<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u4e0b\u8f7d\u4ee3\u7801<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">git<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">clone<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">xxx<\/span><span style=\"color: #D8DEE9FF\"> <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u6253\u5305\u6784\u5efa\uff0c\u8df3\u8fc7\u6d4b\u8bd5<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">mvn<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">package<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-DskipTests<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u540e\u53f0\u542f\u52a8 Spring Boot \u5e94\u7528<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">nohup<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">java<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-jar<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">.\/user-center-backend-0.0.1-SNAPSHOT.jar<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">--spring.profiles.active=prod<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">&gt;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">\/dev\/null<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">2&gt;&amp;1<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&amp;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u67e5\u770b\u5e94\u7528\u542f\u52a8\u60c5\u51b5<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">netstat<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-ntlp<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">|<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">grep<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">java<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Linux\u5b9d\u5854\u9762\u677f\u90e8\u7f72<\/strong><\/p>\n\n\n\n<p>\u9996\u5148\u767b\u5f55\u5b9d\u5854\u9762\u677f\uff0c\u767b\u5f55\u540e\u5728\u7f51\u7ad9\u680f\u4e2d\u7684PHP\u9879\u76ee\u70b9\u51fb\u6dfb\u52a0\u7ad9\u70b9\uff0c\u521b\u5efa\u4e00\u4e2a\u7ad9\u70b9\u4fe1\u606f\uff0c\u57df\u540d\u8fd9\u91cc\u662f\u9700\u8981\u8bbf\u95ee\u54ea\u4e2a\u57df\u540d\u6216ip\u6765\u8bbf\u95ee\u8fd9\u4e2a\u9879\u76ee\uff0c\u6839\u636e\u4e2a\u4eba\u60c5\u51b5\u586b\u5199\u57df\u540d\u6216ip\uff0c\u6839\u76ee\u5f55\u662f\u4f60\u9879\u76ee\u7684\u6839\u8def\u5f84\u4f4d\u7f6e\uff0c\u6240\u6709\u5fc5\u586b\u5185\u5bb9\u586b\u5b8c\u540e\u70b9\u51fb\u63d0\u4ea4<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"958\" height=\"550\" src=\"https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-51.png\" alt=\"\" class=\"wp-image-1009\" srcset=\"https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-51.png 958w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-51-300x172.png 300w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-51-768x441.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\u6b64\u65f6\u5c31\u4f1a\u5e2e\u5fd9\u521b\u5efa\u597d\u4e86\u4e00\u4e2a\u7a7a\u7ad9\u70b9\uff0c\u540c\u65f6\u5e2e\u5fd9\u914d\u7f6e\u597d\u4e86nginx\uff0c\u6211\u4eec\u9700\u8981\u628a\u6211\u4eec\u6253\u5305\u597d\u7684\u524d\u7aef\u9879\u76ee\u6dfb\u52a0\u5230\u6839\u76ee\u5f55\u4e2d\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u91cc\u662f\u5c06dist\u6587\u4ef6\u5939\u4e2d\u7684\u6587\u4ef6\u4ee5\u53ca\u6587\u4ef6\u5939\u653e\u5230\u9879\u76ee\u6839\u76ee\u5f55\u4e2d\uff0c\u800c\u4e0d\u662f\u628adist\u6587\u4ef6\u5939\u653e\u5230\u6839\u76ee\u5f55\u4e2d\uff0c\u8fd9\u6837\u5c31\u4e0d\u9700\u8981\u91cd\u65b0\u914d\u7f6enginx\u7684\u8def\u5f84\u4e86\uff0c\u8fd9\u6837\u524d\u7aef\u9879\u76ee\u5c31\u53ef\u4ee5\u8bbf\u95ee\u4e86<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"524\" src=\"https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-52-1024x524.png\" alt=\"\" class=\"wp-image-1013\" srcset=\"https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-52-1024x524.png 1024w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-52-300x153.png 300w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-52-768x393.png 768w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-52.png 1478w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\u63a5\u4e0b\u6765\u662f\u540e\u7aef\u7684\u90e8\u7f72\uff0c\u70b9\u51fb\u5b9d\u5854\u9762\u677f\u4e2d\u7f51\u7ad9\u90e8\u5206\u7684java\u9879\u76ee\uff0c\u6dfb\u52a0java\u9879\u76ee\u7136\u540e\u586b\u5199\u76f8\u5bf9\u5e94\u7684\u4fe1\u606f\uff0c\u8fd9\u91cc\u5982\u679c\u5b9d\u5854\u9762\u677f\u6ca1\u6709\u5b89\u88c5jdk\u6216\u8005\u7248\u672c\u4e0e\u9879\u76ee\u4e0d\u4e00\u81f4\u4e5f\u6ca1\u6709\u5173\u7cfb\uff0c\u53ef\u4ee5\u5728\u8fd9\u91cc\u9009\u62e9\u6dfb\u52a0jdk\u4fe1\u606f\uff0c\u5b83\u4f1a\u5728\u7f51\u4e0a\u62c9\u53d6\u4e0b\u8f7d\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u9879\u76ee\u4e0d\u540c\u7684jdk\u7248\u672c\u8fdb\u884c\u5207\u6362\uff0c\u5c06\u81ea\u5df1\u6253\u597d\u7684jar\u5305\u4e0a\u4f20\u670d\u52a1\u5668\u540e\u9009\u62e9\u9879\u76ee\u8def\u5f84\uff0c\u586b\u5199\u5b8c\u6574\u4fe1\u606f\u540e\uff0c\u64cd\u4f5c\u6b63\u786e\u7684\u60c5\u51b5\u4e0bjava\u9879\u76ee\u5c31\u4f1a\u81ea\u52a8\u90e8\u7f72\u5e76\u6267\u884c\u4e86\uff0c\u5c31\u8fd9\u4e48\u7b80\u5355\uff0c\u53f3\u8fb9\u6709\u4e00\u4e2ajava\u9879\u76ee\u90e8\u7f72\u7684\u6559\u7a0b\uff0c\u6211\u628a\u5730\u5740\u4e5f\u8d34\u51fa\u6765\u4f9b\u5927\u5bb6\u53c2\u8003\u3010<a href=\"https:\/\/www.bt.cn\/bbs\/thread-76217-1-1.html\">\u5b9d\u5854 \u65b0\u7248Java \u9879\u76ee\u90e8\u7f72\u6559\u7a0b &#8211; Linux\u9762\u677f &#8211; \u5b9d\u5854\u9762\u677f\u8bba\u575b (bt.cn)<\/a>\u3011<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"646\" src=\"https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-53-1024x646.png\" alt=\"\" class=\"wp-image-1015\" srcset=\"https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-53-1024x646.png 1024w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-53-300x189.png 300w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-53-768x484.png 768w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-53-1536x969.png 1536w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-53.png 1692w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\"><strong>docker\u5bb9\u5668\u90e8\u7f72<\/strong><\/p>\n\n\n\n<p>\u8fd8\u8bb0\u5f97\u4e4b\u524d\u5728\u524d\u540e\u7aef\u9879\u76ee\u4e2d\u90fd\u6dfb\u52a0\u4e86dockerfile\u6587\u4ef6\u5427\uff0c\u8fd9\u91cc\u5c31\u53ef\u4ee5\u4f7f\u7528\u54b1\u4eec\u7f16\u5199\u597d\u7684dockerfile\u5bf9\u6211\u4eec\u7684\u9879\u76ee\u8fdb\u884c\u955c\u50cf\u6784\u5efa\u4ee5\u53ca\u5bb9\u5668\u90e8\u7f72\u4e86<\/p>\n\n\n\n<p>\u6839\u636e Dockerfile \u6784\u5efa\u955c\u50cf\uff0c\u6784\u5efa\u65f6\u9700\u8981\u6ce8\u610f\uff0c\u6784\u5efa\u65f6\u6267\u884c\u6784\u5efa\u547d\u4ee4\u7684\u8def\u5f84\u662f\u5426\u65f6\u9879\u76ee\u6839\u76ee\u5f55\u6216\u8005\u8bf4\u5f53\u524d\u76ee\u5f55\u4e0b\u662f\u5426\u6709\u9700\u8981\u6784\u5efa\u7684dockerfile\u6587\u4ef6<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# \u540e\u7aef\ndocker build -t xxx:v0.0.1 .\n\n# \u524d\u7aef\ndocker build -t xxxx:v0.0.1 .\n\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># \u540e\u7aef<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">docker<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">build<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">xxx:v0.0.1<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">.<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u524d\u7aef<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">docker<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">build<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">xxxx:v0.0.1<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">.<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u547d\u4ee4\u89e3\u91ca<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"docker build: \u6839\u636e Dockerfile \u6587\u4ef6\u6784\u5efa Docker \u955c\u50cf\n-t xxx:v1.0.0: \u4e3a\u955c\u50cf\u547d\u540d\u4e3a xxx \u5e76\u6807\u8bb0\u4e3a\u7248\u672c v1.0.0\n.: \u4ee3\u8868\u5f53\u524d\u76ee\u5f55\uff0c\u5373 Docker \u5c06\u5728\u6b64\u5904\u67e5\u627e Dockerfile \u53ca\u7528\u4e8e\u6784\u5efa\u955c\u50cf\u7684\u4e0a\u4e0b\u6587\u6587\u4ef6\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9FF\">docker build: \u6839\u636e Dockerfile \u6587\u4ef6\u6784\u5efa Docker \u955c\u50cf<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">-t xxx:v1.0.0: \u4e3a\u955c\u50cf\u547d\u540d\u4e3a xxx \u5e76\u6807\u8bb0\u4e3a\u7248\u672c v1.0.0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">.: \u4ee3\u8868\u5f53\u524d\u76ee\u5f55\uff0c\u5373 Docker \u5c06\u5728\u6b64\u5904\u67e5\u627e Dockerfile \u53ca\u7528\u4e8e\u6784\u5efa\u955c\u50cf\u7684\u4e0a\u4e0b\u6587\u6587\u4ef6<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u6784\u5efa\u597d\u540e\u53ef\u4ee5\u901a\u8fc7docker -images\u67e5\u8be2\u6240\u6709\u955c\u50cf\uff0c\u786e\u8ba4\u6784\u5efa\u7684\u955c\u50cf\u5b58\u5728\u540e\u542f\u52a8\u955c\u50cf<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# \u524d\u7aef\ndocker run -p 80:80 -d xxxx:v0.0.1\n\n# \u540e\u7aef\ndocker run -p 8080:8080 xxx:v0.0.1\n\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># \u524d\u7aef<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">docker<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">run<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-p<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">80<\/span><span style=\"color: #A3BE8C\">:80<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-d<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">xxxx:v0.0.1<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u540e\u7aef<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">docker<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">run<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-p<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">8080<\/span><span style=\"color: #A3BE8C\">:8080<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">xxx:v0.0.1<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u547d\u4ee4\u89e3\u91ca<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"docker run: \u542f\u52a8\u4e00\u4e2a Docker \u5bb9\u5668\n-p 8080:8080: \u5c06\u4e3b\u673a\u76848080\u7aef\u53e3\u6620\u5c04\u5230\u5bb9\u5668\u76848080\u7aef\u53e3\n-p &lt;\u4e3b\u673a\u7aef\u53e3&gt;:&lt;\u5bb9\u5668\u7aef\u53e3&gt;\n\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9FF\">docker run: \u542f\u52a8\u4e00\u4e2a Docker \u5bb9\u5668<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">-p 8080:8080: \u5c06\u4e3b\u673a\u76848080\u7aef\u53e3\u6620\u5c04\u5230\u5bb9\u5668\u76848080\u7aef\u53e3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">-p <\/span><span style=\"color: #81A1C1\">&lt;\u4e3b\u673a\u7aef\u53e3&gt;<\/span><span style=\"color: #D8DEE9FF\">:<\/span><span style=\"color: #81A1C1\">&lt;\u5bb9\u5668\u7aef\u53e3&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u901a\u8fc7docker ps\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u5df2\u7ecf\u542f\u52a8\u7684docker\u5bb9\u5668\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7docker ps -a\u6765\u67e5\u770b\u5f53\u524ddocker\u4e2d\u6709\u54ea\u4e9b\u5bb9\u5668\uff0c\u901a\u8fc7 docker logs \u5bb9\u5668id\u6216\u5bb9\u5668\u540d\u67e5\u770b\u5bb9\u5668\u65e5\u5fd7<\/p>\n\n\n\n<p>\u76f8\u5173\u547d\u4ee4<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"# \u8fdb\u5165\u5bb9\u5668\ndocker exec -i -t  \u5bb9\u5668id \/bin\/bash\n# \u67e5\u770b\u5bb9\u5668\u8fdb\u7a0b\ndocker ps\n# \u67e5\u770b\u65e5\u5fd7\ndocker logs -f [container-id]\n# \u6740\u6b7b\u5bb9\u5668\ndocker kill\n# \u5f3a\u5236\u5220\u9664\u955c\u50cf\ndocker rmi -f\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># \u8fdb\u5165\u5bb9\u5668<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">docker<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">exec<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-i<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-t<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #A3BE8C\">\u5bb9\u5668id<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">\/bin\/bash<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u67e5\u770b\u5bb9\u5668\u8fdb\u7a0b<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">docker<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">ps<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u67e5\u770b\u65e5\u5fd7<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">docker<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">logs<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-f<\/span><span style=\"color: #D8DEE9FF\"> [container-id]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u6740\u6b7b\u5bb9\u5668<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">docker<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">kill<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># \u5f3a\u5236\u5220\u9664\u955c\u50cf<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">docker<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">rmi<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">-f<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u8fd9\u91cc\u6709\u4e00\u70b9\u9700\u8981\u91cd\u7533\u4e00\u4e0b\uff0c\u5728\u6267\u884cdocker\u955c\u50cf\u6784\u5efa\u65f6\u9700\u8981\u786e\u4fdd\u81ea\u5df1\u9879\u76ee\u4e2d\u7684dockerfile\u6587\u4ef6\u6240\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4\u662f\u5426\u5b8c\u5168\u6b63\u786e\uff0c\u5426\u5219\u6709\u53ef\u80fd\u5728\u8fd0\u884c\u5bb9\u5668\u65f6\u62a5\u9519\uff0c\u62a5\u9519\u4e5f\u4e0d\u8981\u614c\u5f20\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9d\u5854\u9762\u677f\u81ea\u5e26\u7684docker\u7ba1\u7406\u5de5\u5177\u67e5\u770b\u65e5\u5fd7\u4ee5\u53ca\u7ba1\u7406\u5bb9\u5668\u548c\u955c\u50cf<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"255\" src=\"https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-54-1024x255.png\" alt=\"\" class=\"wp-image-1030\" srcset=\"https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-54-1024x255.png 1024w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-54-300x75.png 300w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-54-768x191.png 768w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-54-1536x382.png 1536w, https:\/\/www.coffecat.cn\/wp-content\/uploads\/2024\/10\/image-54-2048x510.png 2048w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\u5728\u524d\u7aef\u7684dockerfile\u4e2d\u8bf7\u6ce8\u610f\u9879\u76ee\u6839\u76ee\u5f55\u4e0bdocker\/nginx\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u4ee3\u7406\u914d\u7f6e\u662f\u5426\u6b63\u786e\uff0c\u8fd9\u91cc\u540c\u6837\u518d\u6b21\u8d34\u51fa\u4ee3\u7406\u914d\u7f6e\u5e76\u518d\u6b21\u5f3a\u8c03\u4ee3\u7406\u914d\u7f6e\u662f\u5426\u6b63\u786e\uff0c\u56e0\u4e3a\u5982\u679c\u8fd9\u91cc\u5b58\u5728\u95ee\u9898\uff0c\u90a3\u4e48\u6784\u5efa\u51fa\u7684\u955c\u50cf\u5728\u5bb9\u5668\u90e8\u7f72\u65f6\u5927\u6982\u7387\u4f1a\u90e8\u7f72\u5931\u8d25\uff0c\u8fd9\u4e5f\u7b97\u662f\u8e29\u8fc7\u6700\u75db\u7684\u4e00\u4e2a\u5751\u4e86<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"   # \u8de8\u57df\u914d\u7f6e\n   location ^~ \/api\/ {\n   # \u8de8\u57df\u914d\u7f6e\n   proxy_pass http:\/\/\u516c\u7f51ip\/api\/;\n   add_header 'Access-Control-Allow-Origin' $http_origin;\n   add_header 'Access-Control-Allow-Credentials' 'true';\n   add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';\n   add_header Access-Control-Allow-Headers '*';\n   if ($request_method = 'OPTIONS') {\n   add_header 'Access-Control-Allow-Credentials' 'true';\n   add_header 'Access-Control-Allow-Origin' $http_origin;\n   add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';\n   add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';\n   add_header 'Access-Control-Max-Age' 1728000;\n   add_header 'Content-Type' 'text\/plain; charset=utf-8';\n   add_header 'Content-Length' 0;\n   return 204;\n   }\n   }\n\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9FF\">   # \u8de8\u57df\u914d\u7f6e<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   location ^~ \/api\/ {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   # \u8de8\u57df\u914d\u7f6e<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   proxy_pass http:\/\/\u516c\u7f51ip\/api\/;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header &#39;Access-Control-Allow-Origin&#39; $http_origin;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header &#39;Access-Control-Allow-Credentials&#39; &#39;true&#39;;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header Access-Control-Allow-Methods &#39;GET, POST, OPTIONS&#39;;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header Access-Control-Allow-Headers &#39;*&#39;;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   if ($request_method = &#39;OPTIONS&#39;) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header &#39;Access-Control-Allow-Credentials&#39; &#39;true&#39;;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header &#39;Access-Control-Allow-Origin&#39; $http_origin;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header &#39;Access-Control-Allow-Methods&#39; &#39;GET, POST, OPTIONS&#39;;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header &#39;Access-Control-Allow-Headers&#39; &#39;DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range&#39;;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header &#39;Access-Control-Max-Age&#39; 1728000;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header &#39;Content-Type&#39; &#39;text\/plain; charset=utf-8&#39;;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   add_header &#39;Content-Length&#39; 0;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   return 204;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   }<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u90a3\u4e48\u81f3\u6b64\u6240\u6709\u7684\u90e8\u7f72\u65b9\u5f0f\u5df2\u7ecf\u5b8c\u6210\u4e86\uff0c\u8bbf\u95ee\u9879\u76ee\u5982\u679c\u53ef\u4ee5\u6b63\u5e38\u8c03\u7528\u5230\u540e\u7aef\u670d\u52a1\u8bf4\u660e\u524d\u540e\u7aef\u5df2\u7ecf\u6253\u901a\u4e86\uff0c\u6574\u4e2a\u9879\u76ee\u7528\u65f6\u5927\u698215\u5929\u5de6\u53f3\uff0c\u5927\u591a\u6570\u65f6\u95f4\u5728\u8e29\u5751\uff0c\u7531\u4e8e\u5e73\u65f6\u90e8\u7f72\u64cd\u4f5c\u6bd4\u8f83\u5c11\uff0c\u6240\u4ee5\u5927\u591a\u6570\u9519\u8bef\u5730\u65b9\u8fd8\u662f\u5728\u914d\u7f6e\u65b9\u9762\uff0c\u597d\u5728\u662f\u901a\u8fc7\u67e5\u9605\u8d44\u6599\u4ee5\u53ca\u901a\u8fc7\u9c7c\u53cb\u7684\u8e29\u5751\u8bb0\u5f55\u89e3\u51b3\u4e86\uff0c\u6b64\u7bc7\u5df2\u5b8c\u7ed3\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7531\u4e8e\u6211\u662f\u4f7f\u7528\u7684\u81ea\u5e26\u5b9d\u5854\u7684Linux\u6240\u4ee5\u6211\u8fd9\u91cc\u4f7f\u7528\u7684\u90e8\u7f72\u65b9\u5f0f\u662f\u5728\u670d\u52a1\u5668\u4e2d\u90e8\u7f72\u4ee5\u53ca\u5728docker\u5bb9\u5668\u4e2d\u90e8\u7f72\uff0c\u4e4b\u524d\u5728 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.coffecat.cn\/index.php\/2024\/10\/09\/%e9%a1%b9%e7%9b%ae%e5%ae%9e%e6%88%98%e8%ae%b0%e5%bd%95-%e3%80%90%e7%94%a8%e6%88%b7%e4%b8%ad%e5%bf%83%e9%a1%b9%e7%9b%ae%e3%80%91%e7%94%a8%e6%88%b7%e4%b8%ad%e5%bf%83%e9%a1%b9%e7%9b%ae%e4%b8%8a%e7%ba%bf\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u9879\u76ee\u5b9e\u6218\u8bb0\u5f55 -\u3010\u7528\u6237\u4e2d\u5fc3\u9879\u76ee\u3011\u7528\u6237\u4e2d\u5fc3\u9879\u76ee\u4e0a\u7ebf\u90e8\u7f72\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,34,33],"tags":[],"class_list":["post-998","post","type-post","status-publish","format-standard","hentry","category-docker","category-34","category-33"],"views":855,"_links":{"self":[{"href":"https:\/\/www.coffecat.cn\/index.php\/wp-json\/wp\/v2\/posts\/998","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.coffecat.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coffecat.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coffecat.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coffecat.cn\/index.php\/wp-json\/wp\/v2\/comments?post=998"}],"version-history":[{"count":30,"href":"https:\/\/www.coffecat.cn\/index.php\/wp-json\/wp\/v2\/posts\/998\/revisions"}],"predecessor-version":[{"id":1033,"href":"https:\/\/www.coffecat.cn\/index.php\/wp-json\/wp\/v2\/posts\/998\/revisions\/1033"}],"wp:attachment":[{"href":"https:\/\/www.coffecat.cn\/index.php\/wp-json\/wp\/v2\/media?parent=998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coffecat.cn\/index.php\/wp-json\/wp\/v2\/categories?post=998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coffecat.cn\/index.php\/wp-json\/wp\/v2\/tags?post=998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}