{"id":36282,"date":"2025-05-09T07:55:57","date_gmt":"2025-05-08T23:55:57","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/36282.html"},"modified":"2025-05-09T07:55:57","modified_gmt":"2025-05-08T23:55:57","slug":"%e4%bd%bf%e7%94%a8%e9%98%bf%e9%87%8c%e4%ba%91%e8%bd%bb%e9%87%8f%e6%9c%8d%e5%8a%a1%e5%99%a8-docker-%e9%83%a8%e7%bd%b2-spring-boot-%e9%a1%b9%e7%9b%ae%e5%ae%9e%e6%88%98%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/36282.html","title":{"rendered":"\u4f7f\u7528\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668 + Docker \u90e8\u7f72 Spring Boot \u9879\u76ee\u5b9e\u6218\u6307\u5357"},"content":{"rendered":"<p>&#x1f3af; \u76ee\u6807&#xff1a;\u4f7f\u7528\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668\u90e8\u7f72\u4e00\u4e2a\u5b8c\u6574\u7684 Spring Boot \u5168\u6808\u9879\u76ee&#xff08;\u5982 hmdp&#xff09;&#xff0c;\u5305\u62ec MySQL\u3001Redis\u3001Nginx \u548c Spring Boot \u5e94\u7528\u3002<\/p>\n<p>&#x1f4a1; \u9002\u5408\u4eba\u7fa4&#xff1a;\u6709\u57fa\u7840 Linux \u64cd\u4f5c\u80fd\u529b\u3001\u4e86\u89e3 Docker \u7684\u5f00\u53d1\u8005&#xff0c;\u9002\u7528\u4e8e\u8bfe\u7a0b\u8bbe\u8ba1\u3001\u6bd5\u4e1a\u8bbe\u8ba1\u6216\u4e2a\u4eba\u9879\u76ee\u4e0a\u7ebf\u3002<\/p>\n<h3>\u4e00\u3001\u524d\u7f6e\u51c6\u5907<\/h3>\n<h4>1. \u51c6\u5907\u4e00\u53f0 Ubuntu \u7cfb\u7edf\u670d\u52a1\u5668<\/h4>\n<p>\u63a8\u8350\u4f7f\u7528 \u963f\u91cc\u4e91\u8f7b\u91cf\u5e94\u7528\u670d\u52a1\u5668&#xff0c;\u5927\u5b66\u751f\u53ef\u4ee5\u514d\u8d39\u7533\u8bf7\u4f7f\u7528&#xff0c;\u914d\u7f6e\u4e3a 2\u68381G&#xff0c;\u5b8c\u5168\u6ee1\u8db3\u5b66\u4e60\u548c\u5c0f\u9879\u76ee\u90e8\u7f72\u9700\u6c42\u3002<\/p>\n<ul>\n<li>\u767b\u5f55\u65b9\u5f0f&#xff1a;\u4f7f\u7528 SSH \u5de5\u5177&#xff08;\u5982 XShell \u6216 Terminal&#xff09;\u8fde\u63a5\u670d\u52a1\u5668<\/li>\n<li>\u63a8\u8350\u4f7f\u7528 root \u7528\u6237\u64cd\u4f5c&#xff0c;\u6216\u8005\u5728\u547d\u4ee4\u524d\u52a0\u00a0sudo<\/li>\n<\/ul>\n<h4 style=\"background-color:transparent\">2. \u5b89\u88c5 Docker<\/h4>\n<p># \u66f4\u65b0\u7cfb\u7edf\u8f6f\u4ef6\u5305\u7d22\u5f15<br \/>\napt update &amp;&amp; apt upgrade -y<\/p>\n<p># \u5b89\u88c5\u4f9d\u8d56\u5305<br \/>\napt install -y apt-transport-https ca-certificates curl software-properties-common<\/p>\n<p># \u6dfb\u52a0 Docker \u5b98\u65b9 GPG \u5bc6\u94a5<br \/>\ncurl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | gpg &#8211;dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg<\/p>\n<p># \u8bbe\u7f6e\u7a33\u5b9a\u4ed3\u5e93\u6e90<br \/>\necho &#034;deb [arch&#061;$(dpkg &#8211;print-architecture) signed-by&#061;\/usr\/share\/keyrings\/docker-archive-keyring.gpg] https:\/\/download.docker.com\/linux\/ubuntu $(lsb_release -cs) stable&#034; | tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null<\/p>\n<p># \u518d\u6b21\u66f4\u65b0\u5e76\u5b89\u88c5 Docker CE<br \/>\napt update<br \/>\napt install -y docker-ce<\/p>\n<p># \u542f\u52a8 Docker \u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<br \/>\nsystemctl enable docker &amp;&amp; systemctl start docker<\/p>\n<p># \u9a8c\u8bc1\u5b89\u88c5<br \/>\ndocker &#8211;version <\/p>\n<h3 style=\"background-color:transparent\">\u4e8c\u3001\u90e8\u7f72mysql<\/h3>\n<p># 1.\u521b\u5efa\u672c\u5730\u6570\u636e\u5b58\u50a8\u76ee\u5f55<br \/>\nmkdir -p ~\/mysql\/data ~\/mysql\/logs<\/p>\n<p># 2.\u62c9\u53d6\u955c\u50cf&#xff08;\u5efa\u8bae\u4f7f\u7528\u957f\u671f\u652f\u6301\u7248\u672c&#xff09;<br \/>\ndocker pull mysql:5.6<\/p>\n<p># 3.\u542f\u52a8\u5bb9\u5668<br \/>\ndocker run -d \\\\<br \/>\n  &#8211;name mysql_1 \\\\<br \/>\n  -p 3306:3306 \\\\<br \/>\n  -v ~\/mysql\/data:\/var\/lib\/mysql \\\\<br \/>\n  -v ~\/mysql\/logs:\/logs \\\\<br \/>\n  -e MYSQL_ROOT_PASSWORD&#061;123456 \\\\<br \/>\n  mysql:5.6 <\/p>\n<p>\u2705 \u53ef\u9009\u64cd\u4f5c&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4f7f\u7528\u5ba2\u6237\u7aef\u5de5\u5177\u8fdc\u7a0b\u8fde\u63a5\u6d4b\u8bd5&#xff08;\u5982 Navicat\u3001DBeaver&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u4fee\u6539\u5bc6\u7801\u3001\u521b\u5efa\u6570\u636e\u5e93\u7b49\u53ef\u901a\u8fc7\u00a0docker exec\u00a0\u8fdb\u5165\u5bb9\u5668\u64cd\u4f5c<\/p>\n<\/li>\n<\/ul>\n<p style=\"background-color:transparent\">\u542f\u52a8\u597d\u53ef\u4ee5\u7528\u672c\u5730\u8fde\u63a5\u6d4b\u8bd5\u4e00\u4e0b<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"415\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250508235555-681d448bb8ea7.png\" width=\"500\" \/><\/p>\n<h3 style=\"background-color:transparent\">\u4e09\u3001\u90e8\u7f72redis<\/h3>\n<p># 1.\u521b\u5efa Redis \u6570\u636e\u4e0e\u914d\u7f6e\u76ee\u5f55<br \/>\nmkdir -p ~\/redis\/data ~\/redis\/conf<\/p>\n<p># 2.\u4e0b\u8f7d\u5b98\u65b9\u914d\u7f6e\u6587\u4ef6\u5e76\u8bbe\u7f6e\u5bc6\u7801<br \/>\ncd ~\/redis\/conf<br \/>\ncurl -O https:\/\/raw.githubusercontent.com\/redis\/redis\/unstable\/redis.conf<\/p>\n<p># 3.\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6&#xff0c;\u6dfb\u52a0\u5bc6\u7801\u8ba4\u8bc1<br \/>\nvim redis.conf<br \/>\n# \u627e\u5230 requirepass \u884c&#xff0c;\u53d6\u6d88\u6ce8\u91ca\u5e76\u8bbe\u7f6e\u5bc6\u7801&#xff0c;\u4f8b\u5982&#xff1a;<br \/>\n# requirepass your_password_here<\/p>\n<p># 4.\u62c9\u53d6\u955c\u50cf<br \/>\ndocker pull redis:latest<\/p>\n<p># 5.\u542f\u52a8\u5bb9\u5668<br \/>\ndocker run -d \\\\<br \/>\n  &#8211;name redis_custom \\\\<br \/>\n  &#8211;restart always \\\\<br \/>\n  -p 6379:6379 \\\\<br \/>\n  -v ~\/redis\/data:\/data \\\\<br \/>\n  -v ~\/redis\/conf\/redis.conf:\/usr\/local\/etc\/redis\/redis.conf \\\\<br \/>\n  redis:latest redis-server \/usr\/local\/etc\/redis\/redis.conf <\/p>\n<p>\u2705 \u53ef\u9009\u64cd\u4f5c&#xff1a;<\/p>\n<ul>\n<li>\u4f7f\u7528\u00a0redis-cli\u00a0\u6d4b\u8bd5\u8fde\u63a5\u548c\u8ba4\u8bc1<\/li>\n<li>\u8bbe\u7f6e\u6301\u4e45\u5316\u7b56\u7565\u3001\u9650\u5236\u6700\u5927\u5185\u5b58\u7b49\u53ef\u5728\u00a0redis.conf\u00a0\u4e2d\u8c03\u6574<\/li>\n<\/ul>\n<p style=\"background-color:transparent\">\u542f\u52a8\u597d\u53ef\u4ee5\u7528\u672c\u5730\u8fde\u63a5\u6d4b\u8bd5\u4e00\u4e0b<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"558\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250508235555-681d448bec4a2.png\" width=\"500\" \/><\/p>\n<h3 style=\"background-color:transparent\">\u56db\u3001\u90e8\u7f72nginx<\/h3>\n<p>\u8fd9\u4e2a\u7a0d\u5fae\u9ebb\u70e6\u4e00\u70b9&#xff0c;\u4e5f\u5c31\u662f\u591a\u4e86\u4e00\u6b65\u4e0a\u4f20\u538b\u7f29\u5305\u5230\u4e91\u7aef&#xff0c;\u89e3\u538b\u8fd9\u4e00\u6b65&#xff0c;\u56e0\u4e3a\u4f60\u8981\u6302\u81ea\u5df1\u7684html\u548cconf\u3002<\/p>\n<h4 style=\"background-color:transparent\">1.\u4e0a\u4f20\u5e76\u89e3\u538b Nginx \u8d44\u6e90\u5305<\/h4>\n<p>\u5c06\u672c\u5730\u6253\u5305\u597d\u7684\u524d\u7aef\u8d44\u6e90&#xff08;\u542b HTML\u3001CSS\u3001JS\u3001\u914d\u7f6e\u6587\u4ef6\u7b49&#xff09;\u4e0a\u4f20\u81f3\u670d\u52a1\u5668&#xff0c;\u4f8b\u5982 \/root\/dockerFiles\/nginx-1.18.0_hmdp2.zip\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"810\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250508235556-681d448c0f526.png\" width=\"1247\" \/><\/p>\n<p>\u5047\u8bbe\u4f60\u5df2\u7ecf\u6709\u4e86 nginx-1.18.0_hmdp2.zip \u5e76\u4e14\u4f4d\u4e8e \/root\/dockerFiles\/ \u76ee\u5f55\u4e0b&#xff1a;\u00a0<\/p>\n<p>unzip nginx-1.18.0_hmdp2.zip -d nginx_hmdp <\/p>\n<h4 style=\"background-color:transparent\">2.\u51c6\u5907\u5bbf\u4e3b\u673a\u76ee\u5f55\u5e76\u590d\u5236\u6587\u4ef6<\/h4>\n<p>mkdir -p ~\/nginx_conf<br \/>\nmkdir -p ~\/nginx_html <\/p>\n<p>\u00a0\u628a\u81ea\u5df1\u9879\u76ee\u7684conf\u548chtml\u590d\u5236\u5230\u5bb9\u5668\u51c6\u5907\u6302\u8f7d\u7684\u76ee\u5f55&#xff08;\u6211\u8fd9\u91cc\u7684root\u4e0b\u9762\u4e24\u4e2a\u6587\u4ef6\u5939\u4e86&#xff0c;\u4f60\u53ef\u4ee5\u653e\u5728\u4e00\u4e2a\u91cc\u9762\u4f8b\u5982&#xff1a;nginx\/nginx_conf\u3001nginx\/nginx_html&#xff09;<\/p>\n<p>cp ~\/dockerFiles\/nginx_hmdp\/nginx-1.18.0_hmdp2\/conf\/nginx.conf ~\/nginx_conf\/nginx.conf<br \/>\ncp -r ~\/dockerFiles\/nginx_hmdp\/nginx-1.18.0_hmdp2\/html\/* ~\/nginx_html\/ <\/p>\n<h4 style=\"background-color:transparent\">3. \u62c9\u53d6\u955c\u50cf\u5e76\u542f\u52a8\u5bb9\u5668<\/h4>\n<p>docker pull nginx:alpine<br \/>\ndocker run -d \\\\<br \/>\n  &#8211;name nginx_hmdp1 \\\\<br \/>\n  -p 80:80 \\\\<br \/>\n  -v ~\/nginx_html:\/usr\/share\/nginx\/html \\\\<br \/>\n  -v ~\/nginx_conf\/nginx.conf:\/etc\/nginx\/nginx.conf<br \/>\n  nginx:alpine <\/p>\n<h4 style=\"background-color:transparent\">4. \u5e38\u89c1\u95ee\u9898\u6392\u67e5<\/h4>\n<p>\u5982\u679c\u9047\u5230\u95ee\u9898&#xff0c;\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u6392\u67e5&#xff1a;<\/p>\n<p>(1) \u68c0\u67e5\u6302\u8f7d\u662f\u5426\u6b63\u786e<\/p>\n<p>\u786e\u8ba4\u6302\u8f7d\u7684\u8def\u5f84\u662f\u5426\u6b63\u786e&#xff0c;\u5e76\u4e14\u5bbf\u4e3b\u673a\u4e0a\u7684\u6587\u4ef6\u786e\u5b9e\u5b58\u5728\u4e8e\u6307\u5b9a\u8def\u5f84&#xff1a;<\/p>\n<p>ls -l ~\/nginx_conf\/nginx.conf<br \/>\nls -l ~\/nginx_html\/ <\/p>\n<p>(2) \u68c0\u67e5 Nginx \u65e5\u5fd7<\/p>\n<p>\u8fdb\u5165\u5bb9\u5668\u67e5\u770b Nginx \u9519\u8bef\u65e5\u5fd7&#xff1a;<\/p>\n<p>docker exec -it nginx_hmdp1 \/bin\/sh<br \/>\ncat \/var\/log\/nginx\/error.log <\/p>\n<p>(3) \u68c0\u67e5 Nginx \u914d\u7f6e\u8bed\u6cd5<\/p>\n<p>\u5728\u5bb9\u5668\u5185\u6d4b\u8bd5 Nginx \u914d\u7f6e\u6587\u4ef6\u8bed\u6cd5&#xff1a;<\/p>\n<p>docker exec -it nginx_hmdp1 \/bin\/sh<br \/>\nnginx -t<br \/>\ndocker run &#8211;rm -it \\\\<br \/>\n  -v ~\/nginx_conf\/nginx.conf:\/etc\/nginx\/conf.d\/nginx.conf \\\\<br \/>\n  nginx:alpine nginx -t <\/p>\n<p>\u5982\u679c\u914d\u7f6e\u6587\u4ef6\u6709\u9519\u8bef&#xff0c;Nginx \u4f1a\u63d0\u793a\u5177\u4f53\u7684\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<h3 style=\"background-color:transparent\">\u4e94\u3001\u90e8\u7f72 Spring Boot \u9879\u76ee&#xff08;\u4ee5 hmdp \u4e3a\u4f8b&#xff09;<\/h3>\n<p>\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u6211\u4eec\u5e38\u5e38\u9700\u8981\u5c06 Spring Boot \u5e94\u7528\u6253\u5305\u5e76\u90e8\u7f72\u5230\u751f\u4ea7\u73af\u5883\u4e2d\u3002\u4f7f\u7528 Docker \u53ef\u4ee5\u5b9e\u73b0\u5e94\u7528\u7684\u5feb\u901f\u6784\u5efa\u3001\u5206\u53d1\u4e0e\u90e8\u7f72\u3002\u672c\u6587\u5c06\u4ee5\u540d\u4e3a hmdp \u7684 Spring Boot \u9879\u76ee\u4e3a\u4f8b&#xff0c;\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7 Dockerfile \u6784\u5efa\u955c\u50cf&#xff0c;\u5e76\u8fd0\u884c\u5bb9\u5668\u5316\u670d\u52a1\u3002<\/p>\n<h4 style=\"background-color:transparent\">1.\u51c6\u5907\u9636\u6bb5&#xff1a;\u4e0a\u4f20 JAR \u5305<\/h4>\n<p>\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a dockerfile&#xff0c;\u7528\u4e8e\u5b9a\u4e49\u955c\u50cf\u7684\u6784\u5efa\u8fc7\u7a0b\u3002\u8fd9\u91cc\u6211\u4eec\u9009\u62e9\u57fa\u4e8e openjdk:8-jdk-alpine \u955c\u50cf&#xff0c;\u5b83\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684 JDK \u73af\u5883<\/p>\n<h5 style=\"background-color:transparent\">&#xff08;1&#xff09;\u6253\u5305 Spring Boot \u5e94\u7528<\/h5>\n<p>\u5728\u672c\u5730\u5f00\u53d1\u73af\u5883\u4e2d&#xff0c;\u4f7f\u7528 IntelliJ IDEA \u6216 Maven \u547d\u4ee4\u5bf9\u9879\u76ee\u8fdb\u884c\u6e05\u7406\u548c\u6253\u5305&#xff1a;<\/p>\n<p>\u7528idea\u7684maven\u5148clean\u4e00\u4e0b\u518dpackage\u4e00\u4e0b\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"510\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250508235556-681d448c61c6f.png\" width=\"480\" \/><\/p>\n<h5 style=\"background-color:transparent\">&#xff08;2&#xff09;\u4e0a\u4f20 JAR \u5230\u670d\u52a1\u5668<\/h5>\n<p>\u4f7f\u7528\u5de5\u5177\u5982 XFTP \u6216 SCP \u5c06\u751f\u6210\u7684 JAR \u5305\u4e0a\u4f20\u81f3\u670d\u52a1\u5668\u7684\u76ee\u6807\u76ee\u5f55&#xff0c;\u4f8b\u5982 \/root\/dockerFiles\/\u3002<\/p>\n<p>\u786e\u4fdd Dockerfile \u548c JAR \u5305\u5904\u4e8e\u540c\u4e00\u76ee\u5f55\u4e0b&#xff0c;\u4fbf\u4e8e\u540e\u7eed\u6784\u5efa\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"292\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250508235556-681d448c72c08.png\" width=\"591\" \/><\/p>\n<h4 style=\"background-color:transparent\">2.\u7f16\u5199 Dockerfile \u5e76\u6784\u5efa\u955c\u50cf<\/h4>\n<h5 style=\"background-color:transparent\">&#xff08;1&#xff09;\u521b\u5efa Dockerfile \u6587\u4ef6<\/h5>\n<p>\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a Dockerfile&#xff0c;\u7528\u4e8e\u5b9a\u4e49\u955c\u50cf\u7684\u6784\u5efa\u8fc7\u7a0b\u3002\u8fd9\u91cc\u6211\u4eec\u9009\u62e9\u57fa\u4e8e openjdk:8-jdk-alpine \u955c\u50cf&#xff0c;\u5b83\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684 JDK \u73af\u5883\u3002<\/p>\n<p>vim \/root\/dockerFiles\/springboot_dockerfile<br \/>\n# \u4f7f\u7528 openjdk:8-jdk-alpine \u955c\u50cf&#xff08;\u8f7b\u91cf\u5316\u7248\u672c&#xff09;<br \/>\nFROM openjdk:8-jdk-alpine<\/p>\n<p># \u7ef4\u62a4\u8005\u4fe1\u606f&#xff08;\u5efa\u8bae\u6539\u7528 LABEL \u6307\u4ee4&#xff09;<br \/>\nLABEL maintainer&#061;&#034;lfq &lt;lfq&#064;lfq.cn&gt;&#034;<br \/>\n# \u6dfb\u52a0 Spring Boot \u5e94\u7528\u7684 JAR \u6587\u4ef6<br \/>\nADD hm-dianping-0.0.1-SNAPSHOT.jar app.jar<br \/>\n# \u542f\u52a8\u547d\u4ee4<br \/>\nENTRYPOINT [&#034;java&#034;, &#034;-jar&#034;, &#034;\/app.jar&#034;] <\/p>\n<h5 style=\"background-color:transparent\">&#xff08;2&#xff09;\u6784\u5efa Docker \u955c\u50cf<\/h5>\n<p>\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u6784\u5efa\u955c\u50cf&#xff1a;<\/p>\n<p>docker build -f .\/springboot_dockerfile -t hmdp . <\/p>\n<h4 style=\"background-color:transparent\">3.\u8fd0\u884c\u5bb9\u5668\u5e76\u6302\u8f7d\u914d\u7f6e\u6587\u4ef6<\/h4>\n<p>\u4e3a\u4e86\u4fbf\u4e8e\u7ef4\u62a4\u548c\u66f4\u65b0\u914d\u7f6e&#xff0c;\u63a8\u8350\u5c06 Spring Boot \u5e94\u7528\u7684\u914d\u7f6e\u6587\u4ef6&#xff08;\u5982 application.yaml&#xff09;\u4ece\u5bb9\u5668\u5916\u90e8\u6302\u8f7d\u8fdb\u53bb\u3002<\/p>\n<h5 style=\"background-color:transparent\">&#xff08;1&#xff09;\u51c6\u5907\u5bbf\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6<\/h5>\n<p>\u5728\u670d\u52a1\u5668\u4e0a\u521b\u5efa\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55\u5e76\u653e\u7f6e\u4f60\u7684 application.yaml&#xff0c;\u4f60\u53ef\u4ee5\u81ea\u5df1\u5199\u4e5f\u53ef\u4ee5\u4e0a\u4f20\u90fd\u884c\u3002<\/p>\n<p>mkdir -p \/root\/myapp\/config<br \/>\ncp application.yaml \/root\/myapp\/config\/ <\/p>\n<h5>&#xff08;2&#xff09;\u8fd0\u884c\u5bb9\u5668\u5e76\u6302\u8f7d\u914d\u7f6e<\/h5>\n<p>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u5bb9\u5668&#xff1a;<\/p>\n<p>docker run -d \\\\<br \/>\n    &#8211;name hmdp_new \\\\<br \/>\n    -v \/root\/myapp\/config\/application.yaml:\/app\/config\/application.yaml \\\\<br \/>\n    -p 8088:8088 \\\\<br \/>\n    hmdp <\/p>\n<p>\u53c2\u6570\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>-d&#xff1a;\u540e\u53f0\u8fd0\u884c\u5bb9\u5668<\/p>\n<\/li>\n<li>\n<p>&#8211;name&#xff1a;\u6307\u5b9a\u5bb9\u5668\u540d\u79f0<\/p>\n<\/li>\n<li>\n<p>-v&#xff1a;\u5c06\u5bbf\u4e3b\u673a\u7684\u914d\u7f6e\u6587\u4ef6\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u90e8\u8def\u5f84<\/p>\n<\/li>\n<li>\n<p>-p&#xff1a;\u6620\u5c04\u5bb9\u5668\u7aef\u53e3\u5230\u5bbf\u4e3b\u673a&#xff08;\u672c\u4f8b\u4e3a 8088&#xff09;<\/p>\n<\/li>\n<\/ul>\n<h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<p>\u672c\u6587\u8be6\u7ec6\u8bb2\u89e3\u4e86\u5982\u4f55\u5728\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668\u4e0a\u4f7f\u7528 Docker \u90e8\u7f72\u4e00\u4e2a\u5b8c\u6574\u7684 Spring Boot \u9879\u76ee&#xff08;hmdp&#xff09;&#xff0c;\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>Docker \u5b89\u88c5\u914d\u7f6e<\/li>\n<li>MySQL\u3001Redis\u3001Nginx\u3001Spring Boot \u5e94\u7528\u7684\u90e8\u7f72<\/li>\n<li>\u5e38\u7528\u53c2\u6570\u8bf4\u660e\u4e0e\u95ee\u9898\u6392\u67e5\u6280\u5de7<\/li>\n<li>\u5b89\u5168\u6027\u4e0e\u7075\u6d3b\u6027\u4f18\u5316\u5efa\u8bae<\/li>\n<\/ul>\n<p>&#x1f4cc; \u6269\u5c55\u9605\u8bfb&#xff1a;<\/p>\n<ul>\n<li>Docker \u5b98\u65b9\u6587\u6863<\/li>\n<li>Spring Boot with Docker<\/li>\n<li>Docker Compose \u5b9e\u6218\u6559\u7a0b<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb846\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf9\u6b21\u3002Docker \u5b89\u88c5\u914d\u7f6eMySQL\u3001Redis\u3001Nginx\u3001Spring Boot \u5e94\u7528\u7684\u90e8\u7f72\u5e38\u7528\u53c2\u6570\u8bf4\u660e\u4e0e\u95ee\u9898\u6392\u67e5\u6280\u5de7\u5b89\u5168\u6027\u4e0e\u7075\u6d3b\u6027\u4f18\u5316\u5efa\u8bae\ud83d\udccc\u6269\u5c55\u9605\u8bfbDocker \u5b98\u65b9\u6587\u6863Docker Compose \u5b9e\u6218\u6559\u7a0b\u3002<\/p>\n","protected":false},"author":2,"featured_media":36277,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,58,1271,3130,96],"topic":[],"class_list":["post-36282","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-docker","tag-linux","tag-springboot","tag-3130","tag-96"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668 + Docker \u90e8\u7f72 Spring Boot \u9879\u76ee\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/36282.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668 + Docker \u90e8\u7f72 Spring Boot \u9879\u76ee\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb846\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf9\u6b21\u3002Docker \u5b89\u88c5\u914d\u7f6eMySQL\u3001Redis\u3001Nginx\u3001Spring Boot \u5e94\u7528\u7684\u90e8\u7f72\u5e38\u7528\u53c2\u6570\u8bf4\u660e\u4e0e\u95ee\u9898\u6392\u67e5\u6280\u5de7\u5b89\u5168\u6027\u4e0e\u7075\u6d3b\u6027\u4f18\u5316\u5efa\u8bae\ud83d\udccc\u6269\u5c55\u9605\u8bfbDocker \u5b98\u65b9\u6587\u6863Docker Compose \u5b9e\u6218\u6559\u7a0b\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/36282.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-08T23:55:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250508235555-681d448bb8ea7.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/36282.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/36282.html\",\"name\":\"\u4f7f\u7528\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668 + Docker \u90e8\u7f72 Spring Boot \u9879\u76ee\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-08T23:55:57+00:00\",\"dateModified\":\"2025-05-08T23:55:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/36282.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/36282.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/36282.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668 + Docker \u90e8\u7f72 Spring Boot \u9879\u76ee\u5b9e\u6218\u6307\u5357\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668 + Docker \u90e8\u7f72 Spring Boot \u9879\u76ee\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/36282.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668 + Docker \u90e8\u7f72 Spring Boot \u9879\u76ee\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb846\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf9\u6b21\u3002Docker \u5b89\u88c5\u914d\u7f6eMySQL\u3001Redis\u3001Nginx\u3001Spring Boot \u5e94\u7528\u7684\u90e8\u7f72\u5e38\u7528\u53c2\u6570\u8bf4\u660e\u4e0e\u95ee\u9898\u6392\u67e5\u6280\u5de7\u5b89\u5168\u6027\u4e0e\u7075\u6d3b\u6027\u4f18\u5316\u5efa\u8bae\ud83d\udccc\u6269\u5c55\u9605\u8bfbDocker \u5b98\u65b9\u6587\u6863Docker Compose \u5b9e\u6218\u6559\u7a0b\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/36282.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-08T23:55:57+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250508235555-681d448bb8ea7.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/36282.html","url":"https:\/\/www.wsisp.com\/helps\/36282.html","name":"\u4f7f\u7528\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668 + Docker \u90e8\u7f72 Spring Boot \u9879\u76ee\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-08T23:55:57+00:00","dateModified":"2025-05-08T23:55:57+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/36282.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/36282.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/36282.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528\u963f\u91cc\u4e91\u8f7b\u91cf\u670d\u52a1\u5668 + Docker \u90e8\u7f72 Spring Boot \u9879\u76ee\u5b9e\u6218\u6307\u5357"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/36282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=36282"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/36282\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/36277"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=36282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=36282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=36282"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=36282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}