{"id":28456,"date":"2025-04-20T00:26:26","date_gmt":"2025-04-19T16:26:26","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/28456.html"},"modified":"2025-04-20T00:26:26","modified_gmt":"2025-04-19T16:26:26","slug":"docker-compose%e6%90%ad%e5%bb%baminio%e5%af%b9%e8%b1%a1%e5%ad%98%e5%82%a8%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/28456.html","title":{"rendered":"docker-compose\u642d\u5efaminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668"},"content":{"rendered":"<h2>docker-compose\u642d\u5efaminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668<\/h2>\n<p>\u6700\u8fd1\u60f3\u4f7f\u7528oss\u5bf9\u8c61\u5b58\u50a8\u8fdb\u884c\u7528\u6237\u56fe\u7247\u4e0a\u4f20\u7684\u7ba1\u7406\uff0c\u4e86\u89e3\u4e86\u4e00\u4e0b\u4f8b\u5982aliyun\u6216\u8005\u817e\u8baf\u4e91\u7684oss\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff0c\u4f46\u662f\u5462\u6d89\u53ca\u5230\u5bf9\u8c61\u5b58\u50a8\u4ee5\u53ca\u7ecf\u8d39\u6709\u9650\u7684\u7f18\u6545\uff0c\u51b3\u5b9a\u81ea\u5df1\u624b\u52a8\u642d\u5efa\u4e00\u4e2aoss\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668\uff1b<\/p>\n<p>\u9996\u5148\u5927\u81f4\u4e86\u89e3\u4e00\u4e0b\u5bf9\u8c61\u5b58\u50a8\uff1a<\/p>\n<p>\u5bf9\u8c61\u5b58\u50a8OSS\uff08Object Storage Service\uff09\u662f\u4e00\u79cd\u4e91\u5b58\u50a8\u670d\u52a1\uff0c\u5b83\u63d0\u4f9b\u4e86\u6d77\u91cf\u3001\u5b89\u5168\u3001\u4f4e\u6210\u672c\u3001\u9ad8\u53ef\u9760\u7684\u5b58\u50a8\u89e3\u51b3\u65b9\u6848<\/p>\n<p>\u7136\u540e\u5728\u7ecf\u8fc7\u5927\u81f4\u4e86\u89e3\u540e\uff0c\u9009\u62e9\u4e86MiNiO\uff0c\u8fdb\u884coss\u5bf9\u8c61\u670d\u52a1\u5668\u7684\u642d\u5efa\u5de5\u4f5c\uff0cMinIO\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u5b83\u517c\u5bb9Amazon S3 API\uff0c\u5e76\u63d0\u4f9b\u9ad8\u6027\u80fd\u3001\u9ad8\u53ef\u7528\u6027\u7684\u5b58\u50a8\u89e3\u51b3\u65b9\u6848\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Docker Compose\u5feb\u901f\u90e8\u7f72MinIO\u3002<\/p>\n<h3>\u4e00\u3001docker-compose\u4e2d\u7684minio\u5bf9\u8c61\u670d\u52a1\u90e8\u7f72<\/h3>\n<h4>\u51c6\u5907\u5de5\u4f5c\uff1a<\/h4>\n<p>1\u3001\u670d\u52a1\u5668\u5fc5\u987b\u5b89\u88c5docker<\/p>\n<p>2\u3001\u670d\u52a1\u5668\u5fc5\u987b\u5b89\u88c5docker\u5bf9\u5e94\u7248\u672c\u7684docker-compose<\/p>\n<h4>1.1\u83b7\u53d6\u955c\u50cf\uff1a<\/h4>\n<p>\u9996\u5148\uff0c\u5982\u679c\u4f60\u7684docker\u8fd8\u80fd\u8fde\u4e0a\u7f51\uff0c\u80fd\u591f\u901a\u8fc7docker pull\u76f8\u5173\u7684\u955c\u50cf\uff08\u54b3\u54b3\uff0c\u6700\u8fd1docker\u4e0d\u5bf9\u52b2\uff0c\u62c9\u53d6\u4e0d\u5230\u955c\u50cf\uff09\uff0c\u5982\u679c\u53ef\u4ee5\u62c9\u53d6\u955c\u50cf\uff0c\u53ef\u4ee5\u6267\u884c\u4e0b\u8ff0\u547d\u4ee4\uff1a<\/p>\n<p><span class=\"token function\">docker<\/span> pull minio\/minio:latest<\/p>\n<p>\u5982\u679c\u4e0d\u53ef\u4ee5\uff0c\u5efa\u8bae\u5728\u5f80\u4e0a\u4e0b\u8f7d\u4e00\u4e2aminio\u7684tar\u5305\uff0c\u4e0a\u4f20\u81f3\u670d\u52a1\u5668\u540e\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p><span class=\"token function\">docker<\/span> load <span class=\"token parameter variable\">-i<\/span> minio.tar  <span class=\"token comment\">## minio \u662f\u4f60\u81ea\u5df1tar\u5305\u7684\u540d\u5b57\u3002<\/span><\/p>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u64cd\u4f5c\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 docker images  \u8fdb\u884c\u67e5\u770b\u83b7\u53d6\u5230\u7684\u955c\u50cf <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419162623-6803ceaf672f7.png\" alt=\"\u8bf7\u6dfb\u52a0\u56fe\u7247\u63cf\u8ff0\"><\/p>\n<h4>1.2 docker-compose.yml\u6587\u4ef6\u5236\u4f5c<\/h4>\n<p><span class=\"token function\">vim<\/span> docker-compose.yml<\/p>\n<p>\u5148\u8d34\u4e00\u4e2a\u4ee3\u7801\u53ed\uff0c\u4e00\u4f1a\u513f\u6328\u4e2a\u513f\u89e3\u91ca\uff1a<\/p>\n<p><span class=\"token key atrule\">version<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">\\&#8217;3\\&#8217;<\/span><br \/>\n<span class=\"token key atrule\">services<\/span><span class=\"token punctuation\">:<\/span><br \/>\n  <span class=\"token key atrule\">minio<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token key atrule\">image<\/span><span class=\"token punctuation\">:<\/span> minio\/minio<br \/>\n    <span class=\"token key atrule\">container_name<\/span><span class=\"token punctuation\">:<\/span> minio<br \/>\n    <span class=\"token key atrule\">ports<\/span><span class=\"token punctuation\">:<\/span><br \/>\n      <span class=\"token punctuation\">&#8211;<\/span> 9010<span class=\"token punctuation\">:<\/span><span class=\"token number\">9000<\/span><br \/>\n      <span class=\"token punctuation\">&#8211;<\/span> 9011<span class=\"token punctuation\">:<\/span><span class=\"token number\">9011<\/span><br \/>\n    <span class=\"token key atrule\">environment<\/span><span class=\"token punctuation\">:<\/span><br \/>\n      <span class=\"token key atrule\">TZ<\/span><span class=\"token punctuation\">:<\/span> Asia\/Shanghai<br \/>\n      <span class=\"token key atrule\">MINIO_ACCESS_KEY<\/span><span class=\"token punctuation\">:<\/span> minio<br \/>\n      <span class=\"token key atrule\">MINIO_SECRET_KEY<\/span><span class=\"token punctuation\">:<\/span> minio123<br \/>\n    <span class=\"token key atrule\">volumes<\/span><span class=\"token punctuation\">:<\/span><br \/>\n      <span class=\"token punctuation\">&#8211;<\/span> .\/data<span class=\"token punctuation\">:<\/span>\/data<br \/>\n    <span class=\"token key atrule\">command<\/span><span class=\"token punctuation\">:<\/span> server \/data <span class=\"token punctuation\">&#8211;<\/span><span class=\"token punctuation\">&#8211;<\/span>console<span class=\"token punctuation\">&#8211;<\/span>address \\&#8221;<span class=\"token punctuation\">:<\/span>9011\\&#8221;<\/p>\n<p>\u5927\u6982\u914d\u7f6e\u5982\u4e0a\u6240\u793a\uff0c\u6709\u51e0\u70b9\u6ce8\u610f<\/p>\n<p>\u6ce8\uff1a<\/p>\n<p>1\u3001minio\u5bb9\u5668\u9ed8\u8ba4\u4f7f\u7528\u4e24\u4e2a\u7aef\u53e3\uff0c9000\u548c9001 9000\u7aef\u53e3\u4e3b\u8981\u9002\u7528\u4e8e\u6570\u636e\u4f20\u8f93\uff0c9001\u7aef\u53e3\u4e3b\u8981\u662f\u7528\u4e8e\u7ba1\u7406\u754c\u9762\uff0c\u4e0a\u8ff0\u6587\u4ef6\u4e2d\u6211\u4e3a\u4e86\u597d\u8bb0\u4e14\u907f\u514d\u7aef\u53e3\u51b2\u7a81\uff0c\u5c069000\u7aef\u53e3\u6620\u5c04\u5230\u4e86\u670d\u52a1\u5668\u76849010\u7aef\u53e3\uff0c\u5c069001\u7aef\u53e3\u6539\u6210\u4e869011\u5e76\u6620\u5c04\u5230\u4e86\u670d\u52a1\u5668\u76849011\u7aef\u53e3<\/p>\n<p>2\u3001\u6570\u636e\u5377\u6620\u5c04\uff1a \u9ed8\u8ba4\u5c06\u6570\u636e\u5377\u6620\u5c04\u5230\u4e86docker-compose.yml\u540c\u6587\u4ef6\u76ee\u5f55\u4e0b\u7684data\u6587\u4ef6\u5939<\/p>\n<p>3\u3001command: server &#8211;console-address \u2018:9011\u2019 \/data \u8fd9\u884c\u4e00\u5b9a\u8981\u52a0\uff0c\u5426\u5219\u7aef\u53e3\u53f7\u662f\u968f\u673a\u7684\uff0c\u4f60\u538b\u6839\u6620\u5c04\u4e0d\u51fa\u53bb<\/p>\n<p>4\u3001\u65b0\u7248\u672c\u4e2d\u7528\u6237\u540d\u548c\u5bc6\u7801\u6539\u7528\u6210\u4e86 \u201cMINIO_ROOT_USER\u201d \u548c \u201cMINIO_ROOT_PASSWORD\u201d \u65e7\u7248\u672c\u662f \u201cMINIO_ACCESS_KEY\u201d \u548c \u201cMINIO_SECRET_KEY\u201d \u53ef\u4ee5\u81ea\u5df1\u6309\u7167\u7248\u672c\u8fdb\u884c\u8bbe\u7f6e\u3002<\/p>\n<p>5\u30014\u4e2d\u5206\u522b\u5bf9\u5e94\u7684\u662f\u7ba1\u7406\u754c\u9762\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801<\/p>\n<p>\u5728\u7f16\u8f91docker-compose.yml\u5e76\u4fdd\u5b58\u540e\uff0c\u901a\u8fc7\u4e0b\u8ff0\u547d\u4ee4\u521b\u5efa\u5e76\u542f\u52a8minio\u5bb9\u5668<\/p>\n<p><span class=\"token comment\">#\u5982\u679c\u4f60\u7684docker-compose.yml\u6587\u4ef6\u4e2d\u6709\u597d\u51e0\u4e2a\u5bb9\u5668\uff0c\u4f60\u5e76\u4e0d\u60f3\u542f\u52a8\u5176\u4ed6\u5bb9\u5668\uff0c\u53ea\u60f3\u542f\u52a8minio<\/span><br \/>\n<span class=\"token function\">docker-compose<\/span> up <span class=\"token parameter variable\">-d<\/span> minio<br \/>\n<span class=\"token comment\">#\u5982\u679c\u4f60\u7684docker-compose.yml\u6587\u4ef6\u4e2d\u53ea\u6709\u76ee\u524d\u7684minio<\/span><br \/>\n<span class=\"token function\">docker-compose<\/span> up <span class=\"token parameter variable\">-d<\/span> <\/p>\n<p>\u542f\u52a8\u6210\u529f\u540e\u4f1a\u770b\u5230\u670d\u52a1\u5668\u663e\u793a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419162623-6803ceaf8a6bc.png\" alt=\"\u8bf7\u6dfb\u52a0\u56fe\u7247\u63cf\u8ff0\"><\/p>\n<p>\u6b64\u65f6\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u8f93\u5165 \u4e0a\u9762docker-compose.yml\u6587\u4ef6\u4e2d\u7684\u3010\u4f60\u81ea\u5df1\u7684IP+9011\u3011 \u8bbf\u95eeminio\u7684\u63a7\u5236\u9762\u677f\uff0c\u8bb0\u5f97\u5f00\u542f\u9632\u706b\u58999010\uff0c9011\u7aef\u53e3\u54df~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419162623-6803ceafaed4b.png\" alt=\"\u8bf7\u6dfb\u52a0\u56fe\u7247\u63cf\u8ff0\"><\/p>\n<p>\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u767b\u5f55minio\u63a7\u5236\u9762\u677f<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419162624-6803ceb070803.png\" alt=\"\u8bf7\u6dfb\u52a0\u56fe\u7247\u63cf\u8ff0\"><\/p>\n<p>\u81f3\u6b64\u5462 \u5355\u673a\u7248\u672c \u901a\u8fc7docker-compose \u90e8\u7f72minio\u5bf9\u8c61\u5b58\u50a8\u7ed3\u675f<\/p>\n<h3>\u4e8c\u3001spring-boot \u96c6\u6210 minio \u5bf9\u8c61\u5b58\u50a8<\/h3>\n<h4>1\u3001\u81ea\u5df1\u521b\u5efaspring-boot \u5de5\u7a0b\uff0c\u5728\u8fd9\u91cc\u4e0d\u591a\u8d58\u8ff0<\/h4>\n<h4>2\u3001\u5f15\u5165pom\u4f9d\u8d56<\/h4>\n<p>\u5728\u81ea\u5df1\u7684boot\u9879\u76ee\u4e2d\u5f15\u5165minio\u4f9d\u8d56<\/p>\n<p><span class=\"token comment\">&lt;!&#8212;minio cos\u5bf9\u8c61\u5b58\u50a8&#8211;&gt;<\/span><br \/>\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>dependency<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>groupId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>io.minio<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>groupId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>artifactId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>minio<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>artifactId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>version<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>8.4.0<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>version<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>dependency<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<h4>3\u3001\u96c6\u6210\u4ee3\u7801<\/h4>\n<p>\u5728\u96c6\u6210\u4ee3\u7801\u4e4b\u524d\u5462\uff0c\u9996\u5148\u4e86\u89e3\u4e00\u4e0bminio\u7684\u51e0\u4e2a\u77e5\u8bc6\u70b9<\/p>\n<ul>\n<li>Object\uff1a\u5b58\u50a8\u5230Minio\u7684\u57fa\u672c\u5bf9\u8c61\uff0c\u5982\u6587\u4ef6\u3001\u5b57\u8282\u6d41\u3001Anything\u2026<\/li>\n<li>Bucket\uff1a\u7528\u6765\u5b58\u50a8Object\u7684\u903b\u8f91\u7a7a\u95f4\u3002\u6bcf\u4e2aBucket\u4e4b\u95f4\u7684\u6570\u636e\u91cf\u662f\u4e92\u76f8\u9694\u79bb\u7684\u3002\u5bf9\u4e8e\u5ba2\u6237\u7aef\u800c\u8a00\uff0c\u5c31\u76f8\u5f53\u4e8e\u4e00\u4e2a\u5b58\u653e\u6587\u4ef6\u7684\u9876\u5c42\u6587\u4ef6\u5939\u3002<\/li>\n<li>Drive\uff1a\u5373\u5b58\u50a8\u6570\u636e\u7684\u78c1\u76d8\uff0c\u5728Minio\u542f\u52a8\u65f6\uff0c\u4ee5\u53c2\u6570\u7684\u65b9\u5f0f\u4f20\u5165\u3002Minio\u4e2d\u6240\u6709\u7684\u5bf9\u8c61\u6570\u636e\u90fd\u4f1a\u5b58\u50a8\u5728Drive\u91cc\u3002<\/li>\n<li>Set\uff1a\u5373\u4e00\u7ec4Drive\u7684\u96c6\u5408\uff0c\u5206\u5e03\u5f0f\u90e8\u7f72\u6839\u636e\u96c6\u7fa4\u89c4\u6a21\u81ea\u52a8\u5212\u5206\u4e00\u4e2a\u6216\u591a\u4e2aSet\uff0c\u6bcf\u4e2aSet\u4e2d\u7684Drive\u5206\u5e03\u5728\u4e0d\u540c\u4f4d\u7f6e\u3002\u4e00\u4e2a\u5bf9\u8c61\u5b58\u50a8\u5728\u4e00\u4e2aSet\u4e0a.\uff08for example:{1\u202664} is divided into 4 sets each of size 16\uff09\n<ul>\n<li>\u4e00\u4e2a\u5bf9\u8c61\u5b58\u50a8\u5728\u4e00\u4e2aSet\u4e0a<\/li>\n<li>\u4e00\u4e2a\u96c6\u7fa4\u5212\u5206\u4e3a\u591a\u4e2aSet<\/li>\n<li>\u4e00\u4e2aSet\u5305\u542b\u7684Drive\u6570\u91cf\u662f\u56fa\u5b9a\u7684\uff0c\u9ed8\u8ba4\u7531\u7cfb\u7edf\u6839\u636e\u96c6\u7fa4\u89c4\u6a21\u81ea\u52a8\u8ba1\u7b97\u5f97\u51fa<\/li>\n<li>\u4e00\u4e2aSet\u4e2d\u6211\u7684Drive\u5c3d\u53ef\u80fd\u5206\u5e03\u5728\u4e0d\u540c\u7684\u8282\u70b9\u4e0a<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>3.1 \u521b\u5efa\u7528\u6237\uff0c\u521b\u5efa\u6876<\/h5>\n<p>\u53ef\u4ee5\u5728minio\u63a7\u5236\u9762\u677f\u8fdb\u884c\u7528\u6237\u7684\u521b\u5efa\u4ee5\u53ca\u5b58\u50a8\u6876\uff08bucket\uff09\u7684\u521b\u5efa\u3002\u6211\u4eec\u521b\u5efa\u4e00\u4e2atest\u7684\u6876\u4ee5\u53ca\u521b\u5efa\u4e00\u4e2a\u7528\u6237\u5e76\u8d4b\u4e88\u8bfb\u5199\u7684\u6743\u9650<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419162625-6803ceb110314.png\" alt=\"\u8bf7\u6dfb\u52a0\u56fe\u7247\u63cf\u8ff0\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419162625-6803ceb16b36f.png\" alt=\"\u8bf7\u6dfb\u52a0\u56fe\u7247\u63cf\u8ff0\"><\/p>\n<h5>3.2 \u6dfb\u52a0application.yml\u914d\u7f6e\u6587\u4ef6<\/h5>\n<p><span class=\"token key atrule\">minio<\/span><span class=\"token punctuation\">:<\/span><br \/>\n  <span class=\"token key atrule\">url<\/span><span class=\"token punctuation\">:<\/span> http<span class=\"token punctuation\">:<\/span>\/\/xxxxxxx <span class=\"token comment\">#Minio\u670d\u52a1\u6240\u5728\u5730\u5740<\/span><br \/>\n  <span class=\"token key atrule\">bucketName<\/span><span class=\"token punctuation\">:<\/span> xxxxxx <span class=\"token comment\">#\u5b58\u50a8\u6876\u540d\u79f0<\/span><br \/>\n  <span class=\"token key atrule\">accessKey<\/span><span class=\"token punctuation\">:<\/span> testUser <span class=\"token comment\">#\u521b\u5efa\u7528\u6237\u8bbf\u95ee\u7684key <\/span><br \/>\n  <span class=\"token key atrule\">secretKey<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">000000000<\/span> <span class=\"token comment\">#\u521b\u5efa\u7528\u6237 \u8bbf\u95ee\u7684\u79d8\u94a5<\/span><\/p>\n<h5>3.3 \u5f15\u5165\u914d\u7f6e<\/h5>\n<p>\u521b\u5efaMinioConfig \u914d\u7f6e\u6587\u4ef6\uff0c\u5c06MinioClient \u6ce8\u5165\u5bb9\u5668<\/p>\n<p><span class=\"token annotation punctuation\">@Data<\/span><br \/>\n<span class=\"token annotation punctuation\">@Configuration<\/span><br \/>\n<span class=\"token annotation punctuation\">@ConfigurationProperties<\/span><span class=\"token punctuation\">(<\/span>prefix <span class=\"token operator\">=<\/span> <span class=\"token string\">\\&#8221;minio\\&#8221;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">MinioConfig<\/span> <span class=\"token punctuation\">{<br \/>\n   <\/span><\/p>\n<p>    <span class=\"token comment\">\/**<br \/>\n     * \u670d\u52a1\u5730\u5740<br \/>\n     *\/<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">String<\/span> url<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/**<br \/>\n     * \u7528\u6237\u540d<br \/>\n     *\/<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">String<\/span> accessKey<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/**<br \/>\n     * \u5bc6\u7801<br \/>\n     *\/<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">String<\/span> secretKey<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/**<br \/>\n     * \u5b58\u50a8\u6876\u540d\u79f0<br \/>\n     *\/<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">String<\/span> bucketName<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/**<br \/>\n     * \u9884\u89c8\u5230\u671f\u65f6\u95f4\uff08\u5c0f\u65f6\uff09<br \/>\n     *\/<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">Integer<\/span> previewExpiry<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">@Bean<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token class-name\">MinioClient<\/span> <span class=\"token function\">getMinIOClient<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<br \/>\n   <\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token class-name\">MinioClient<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">builder<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">endpoint<\/span><span class=\"token punctuation\">(<\/span>url<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">credentials<\/span><span class=\"token punctuation\">(<\/span>accessKey<span class=\"token punctuation\">,<\/span> secretKey<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">build<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h5>3.4 \u5f15\u5165\u76f8\u5173\u64cd\u4f5c<\/h5>\n<p>\u521b\u5efaMinioCosManger\u6587\u4ef6 \u5c01\u88c5\u4e86minio\u5ba2\u6237\u7aef\u7684\u4e00\u4e9b\u64cd\u4f5c<\/p>\n<p><span class=\"token annotation punctuation\">@Component<\/span><br \/>\n<span class=\"token annotation punctuation\">@Slf4j<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">MinioCosManger<\/span> <span class=\"token punctuation\">{<br \/>\n   <\/span><br \/>\n    <span class=\"token annotation punctuation\">@Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">MinioConfig<\/span> prop<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">@Resource<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">MinioClient<\/span> minioClient<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/**<br \/>\n     * \u67e5\u770b\u5b58\u50a8bucket\u662f\u5426\u5b58\u5728<br \/>\n     *<br \/>\n     * @return boolean<br \/>\n     *\/<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token class-name\">Boolean<\/span> <span class=\"token function\">bucketExists<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span> bucketName<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<br \/>\n   <\/span><br \/>\n        <span class=\"token class-name\">Boolean<\/span> found<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">try<\/span> <span class=\"token punctuation\">{<br \/>\n   <\/span><br \/>\n            found <span class=\"token operator\">=<\/span> minioClient<span class=\"token punctuation\">.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb4.3k\u6b21\uff0c\u70b9\u8d5e21\u6b21\uff0c\u6536\u85cf40\u6b21\u3002\u901a\u8fc7docker-compose \u90e8\u7f72\u5355\u673aminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1_minio docker-compose<\/p>\n","protected":false},"author":2,"featured_media":28450,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,1274,2284,43],"topic":[],"class_list":["post-28456","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-docker","tag-minio","tag-oss","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>docker-compose\u642d\u5efaminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668 - \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\/28456.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"docker-compose\u642d\u5efaminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb4.3k\u6b21\uff0c\u70b9\u8d5e21\u6b21\uff0c\u6536\u85cf40\u6b21\u3002\u901a\u8fc7docker-compose \u90e8\u7f72\u5355\u673aminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1_minio docker-compose\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/28456.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-19T16:26:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419162623-6803ceaf672f7.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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/28456.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/28456.html\",\"name\":\"docker-compose\u642d\u5efaminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T16:26:26+00:00\",\"dateModified\":\"2025-04-19T16:26:26+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/28456.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/28456.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/28456.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"docker-compose\u642d\u5efaminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668\"}]},{\"@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":"docker-compose\u642d\u5efaminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668 - \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\/28456.html","og_locale":"zh_CN","og_type":"article","og_title":"docker-compose\u642d\u5efaminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb4.3k\u6b21\uff0c\u70b9\u8d5e21\u6b21\uff0c\u6536\u85cf40\u6b21\u3002\u901a\u8fc7docker-compose \u90e8\u7f72\u5355\u673aminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1_minio docker-compose","og_url":"https:\/\/www.wsisp.com\/helps\/28456.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T16:26:26+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419162623-6803ceaf672f7.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/28456.html","url":"https:\/\/www.wsisp.com\/helps\/28456.html","name":"docker-compose\u642d\u5efaminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T16:26:26+00:00","dateModified":"2025-04-19T16:26:26+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/28456.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/28456.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/28456.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"docker-compose\u642d\u5efaminio\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u5668"}]},{"@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\/28456","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=28456"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/28456\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/28450"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=28456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=28456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=28456"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=28456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}