{"id":159,"date":"2021-08-10T19:27:25","date_gmt":"2021-08-10T11:27:25","guid":{"rendered":"https:\/\/www.gaohui.xyz\/?p=159"},"modified":"2021-08-10T19:27:26","modified_gmt":"2021-08-10T11:27:26","slug":"%e4%bd%bf%e7%94%a8cos%e4%bd%9c%e4%b8%badocker-registry%e5%ad%98%e5%82%a8","status":"publish","type":"post","link":"https:\/\/www.gaohui.xyz\/?p=159","title":{"rendered":"\u4f7f\u7528COS\u4f5c\u4e3aDocker Registry\u5b58\u50a8"},"content":{"rendered":"\n<p>\u9664\u4e86\u4f7f\u7528\u672c\u5730\u7684\u6587\u4ef6\u7cfb\u7edf\u4f5c\u4e3aDocker repository\u7684\u5b58\u50a8\u4ee5\u5916\uff0cDocker Registry\u8fd8\u53ef\u4ee5\u901a\u8fc7Storage\u00a0 Driver\u652f\u6301\u5176\u4ed6\u5404\u79cd\u7c7b\u578b\u7684\u5b58\u50a8\uff0c\u5176\u4e2d\u5305\u62ecAWS S3\u4ee5\u53caS3\u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u3002\u7531\u4e8e\u817e\u8baf\u4e91\u5bf9\u8c61\u5b58\u50a8COS\u5b8c\u5168\u517c\u5bb9S3\uff0c\u56e0\u6b64\u5728Docker Registry\u4e2d\u914d\u7f6eS3 storage driver\u8bbf\u95eeCOS\uff0c\u4ece\u800c\u5c06Docker image\u6587\u4ef6\u5b58\u653e\u5728COS\uff0c\u8282\u7ea6\u672c\u5730\u7684\u5b58\u50a8\u7a7a\u95f4\u3001\u964d\u4f4e\u4f7f\u7528\u6210\u672c\u3002<\/p>\n\n\n\n<p>\uff08\u53c2\u8003\u6587\u6863\uff1a<a href=\"https:\/\/docs.docker.com\/registry\/storage-drivers\/s3\/\">https:\/\/docs.docker.com\/registry\/storage-drivers\/s3\/<\/a>\uff09<\/p>\n\n\n\n<p>\u4e0b\u9762\u7684\u6b65\u9aa4\u63cf\u8ff0\u4e86\u5982\u4f55\u914d\u7f6eDocker Registry\u7684S3 storage driver\u4ee5\u8bbf\u95eeCOS\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u73af\u5883\u63cf\u8ff0<\/h2>\n\n\n\n<p>\u64cd\u4f5c\u7cfb\u7edf\uff1aUbuntu 18.04.4 LTS<\/p>\n\n\n\n<p>Docker\uff1a19.03.6<\/p>\n\n\n\n<p>docker-compose\uff1a1.26.2<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u914d\u7f6e\u6b65\u9aa4<\/h2>\n\n\n\n<p>1\u3001\u5728\u817e\u8baf\u4e91\u63a7\u5236\u53f0\uff0c\u5efa\u7acb\u5b58\u50a8\u6876example-125000000\uff0c\u5e76\u83b7\u53d6\u6709\u8bbf\u95ee\u8be5\u5b58\u50a8\u6876\u6743\u9650\u8d26\u53f7\u7684secretid\u548csecretkey\u3002<\/p>\n\n\n\n<p>2\u3001\u5b89\u88c5Docker.io\u4ee5\u53cadocker-compose\u8f6f\u4ef6\u3002<\/p>\n\n\n\n<p>3\u3001\u83b7\u53d6Docker Registry\u955c\u50cf\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker pull registry\n<\/pre><\/div>\n\n\n<p>4\u3001\u65b0\u5efadocker-compose.yml\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: yaml; title: ; notranslate\" title=\"\">\nversion: &quot;3&quot;\nservices:\n  registry:\n    image: registry\n    container_name: docker-registry\n    restart: always\n    ports:\n      - &quot;5000:5000&quot;\n    environment:\n       REGISTRY_STORAGE: s3\n       REGISTRY_STORAGE_S3_ACCESSKEY: AKIDxxxxxxxxxxxx\n       REGISTRY_STORAGE_S3_SECRETKEY: xxxxxxxxxxxxxxx\n       REGISTRY_STORAGE_S3_REGION: ap-shanghai\n       REGISTRY_STORAGE_S3_BUCKET: example-125000000\n       REGISTRY_STORAGE_S3_REGIONENDPOINT: cos.ap-shanghai.myqcloud.com\n<\/pre><\/div>\n\n\n<p><strong>REGISTRY_STORAGE\uff1a<\/strong>\u5b58\u50a8\u7684\u7c7b\u578b\uff0c\u4f7f\u7528S3\u53caS3\u517c\u5bb9\u7c7b\u578b\u3002<\/p>\n\n\n\n<p><strong>REGISTRY_STORAGE_S3_ACCESSKEY\uff1a<\/strong>\u8bbf\u95ee\u5b58\u50a8\u6876\u8d26\u53f7\u7684secretid\u3002<\/p>\n\n\n\n<p><strong>REGISTRY_STORAGE_S3_SECRETKEY\uff1a<\/strong>\u8bbf\u95ee\u5b58\u50a8\u6876\u8d26\u53f7\u7684secretkey\u3002<\/p>\n\n\n\n<p><strong>REGISTRY_STORAGE_S3_REGION\uff1a<\/strong>\u5b58\u50a8\u6876\u6240\u5728\u7684\u5730\u57df\uff0c\u4f8b\u5982\u4e0a\u6d77\u5219\u586b\u5199ap-shanghai\u3002<\/p>\n\n\n\n<p><strong>REGISTRY_STORAGE_S3_BUCKET\uff1a<\/strong>\u5b58\u50a8\u6876\u7684\u540d\u5b57\u3002<\/p>\n\n\n\n<p><strong>REGISTRY_STORAGE_S3_REGIONENDPOINT\uff1a<\/strong>COS\u7684endpoint\uff0c\u4ee5\u4e0a\u6d77\u7684\u5b58\u50a8\u6876\u4e3a\u4f8b\uff0c\u586b\u5165cos.ap-shanghai.myqcloud.com\u3002<\/p>\n\n\n\n<p>5\u3001\u7f16\u8f91\/etc\/docker\/daemon.json\u6587\u4ef6\uff0c\u52a0\u5165\u4ee5\u4e0b\u5185\u5bb9\uff0c\u5141\u8bb8http\u65b9\u5f0f\u8bbf\u95eeregistry\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n{\n  &quot;insecure-registries&quot;: &#x5B;\n    &quot;172.17.66.66:5000&quot;\n  ]\n}\n<\/pre><\/div>\n\n\n<p>\u8bf7\u5c06\u4e0a\u4f8b\u4e2d\u7684IP\u5730\u5740\u66ff\u6362\u4e3aDocker Registry\u670d\u52a1\u5668\u7684IP\u3002<\/p>\n\n\n\n<p>6\u3001\u8fdb\u5165\u5230docker-compose.yml\u6587\u4ef6\u6240\u5728\u76ee\u5f55\uff0c\u4f7f\u7528docker-compose\u8fd0\u884cRegistry\u5bb9\u5668\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker-compose up -d\ndocker ps\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u9a8c\u8bc1\u914d\u7f6e<\/h2>\n\n\n\n<p>1\u3001Push\u955c\u50cf\u5230Registry\uff0c\u67e5\u770b\u914d\u7f6e\u662f\u5426\u751f\u6548\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker tag busybox:latest 172.17.66.66:5000\/busybox:latest\ndocker push 172.17.66.66:5000\/busybox:latest\n<\/pre><\/div>\n\n\n<p>2\u3001\u4f7f\u7528\u63a7\u5236\u53f0\u6216\u8005cosbrower\u6d4f\u89c8example-125000000\u5b58\u50a8\u6876\u7684\u6587\u4ef6\uff0c\u770b\u770bdocker\/registry\/v2\/repositories\u76ee\u5f55\u4e0b\u662f\u5426\u6709\u6587\u4ef6\u751f\u6210\uff0c\u786e\u8ba4\u955c\u50cf\u5df2\u7ecf\u5b58\u50a8\u5728COS\u4e0a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9664\u4e86\u4f7f\u7528\u672c\u5730\u7684\u6587\u4ef6\u7cfb\u7edf\u4f5c\u4e3aDocker repository\u7684\u5b58\u50a8\u4ee5\u5916\uff0cDock &hellip; <a href=\"https:\/\/www.gaohui.xyz\/?p=159\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/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":[6,1],"tags":[],"class_list":["post-159","post","type-post","status-publish","format-standard","hentry","category-cos","category-docker"],"_links":{"self":[{"href":"https:\/\/www.gaohui.xyz\/index.php?rest_route=\/wp\/v2\/posts\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gaohui.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gaohui.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gaohui.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gaohui.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=159"}],"version-history":[{"count":1,"href":"https:\/\/www.gaohui.xyz\/index.php?rest_route=\/wp\/v2\/posts\/159\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/www.gaohui.xyz\/index.php?rest_route=\/wp\/v2\/posts\/159\/revisions\/160"}],"wp:attachment":[{"href":"https:\/\/www.gaohui.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gaohui.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gaohui.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}