{"id":672,"date":"2022-01-11T18:14:42","date_gmt":"2022-01-11T10:14:42","guid":{"rendered":"http:\/\/zhuxinyong.com\/?p=672"},"modified":"2022-01-12T23:34:36","modified_gmt":"2022-01-12T15:34:36","slug":"docker-compose-guan-fang-shi-li-bao-cuo","status":"publish","type":"post","link":"https:\/\/zhuxinyong.com\/?p=672","title":{"rendered":"Docker Compose \u5b98\u65b9\u5b9e\u4f8b\u62a5\u9519"},"content":{"rendered":"<p>\u5b98\u65b9\u7ed9\u4e86\u4e00\u4e2a Docker Compose \u7684\u5c0f\u6848\u4f8b\uff1a<\/p>\n<p><a href=\"https:\/\/docs.docker.com\/compose\/gettingstarted\/\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.docker.com\/compose\/gettingstarted\/<\/a><\/p>\n<p>\u5f53\u7136\u6211\u8fd0\u884c\u7684\u4e0d\u662f\u5168\u662f\u6309\u7167\u5b98\u65b9\u7684\uff0c\u53c2\u7167\u4e86\uff1a<a href=\"https:\/\/segmentfault.com\/a\/1190000039739254\" target=\"_blank\" rel=\"noopener\">https:\/\/segmentfault.com\/a\/1190000039739254<\/a> \u8fd9\u4e2a\u3002\u4f46\u662f\u5728\u8fd0\u884c\u7684\u65f6\u5019\u9047\u5230\u4e24\u4e2a\u5c0f\u95ee\u9898\uff1a<\/p>\n<p><strong>1. Docker file \u62a5\u9519<\/strong><\/p>\n<pre><code class=\"language-plain_text\">FROM requires either one or three arguments\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/01\/16418913099773.jpg\" alt=\"\"><\/p>\n<p>\u6539\u4e3a\uff1a<\/p>\n<pre><code class=\"language-plain_text\"># \u4f7f\u7528\u57fa\u7840\u955c\u50cf Python 3.4\nFROM python:3.6-alpine         \n# \u5c06\u5f53\u524d\u76ee\u5f55\u6620\u5c04\u5230\u955c\u50cf`\/code`\u76ee\u5f55\u4e0b     \nADD . \/code                    \n# \u8bbe\u7f6e\u5de5\u4f5c\u76ee\u5f55\u4e3a `\/code`\nWORKDIR \/code                    \n# \u5b89\u88c5 Python \u4f9d\u8d56\u5305\nRUN pip install -r requirements.txt \n# \u542f\u52a8 `app.py` \u7a0b\u5e8f       \nCMD [\"python\", \"app.py\"]            \n<\/code><\/pre>\n<p>\u539f\u56e0\u662f\uff1a\u628a <code>#<\/code> \u6ce8\u91ca\u5f53\u6210\u4e86\u6307\u4ee4\u7684\u53c2\u6570\uff0c\u628a\u6ce8\u91ca\u53e6\u4e00\u8d77\u4e00\u884c\u5c31\u884c\u4e86\u3002<\/p>\n<p><a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/#format\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.docker.com\/engine\/reference\/builder\/#format<\/a><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/01\/16418916003853.jpg\" alt=\"\"><\/p>\n<p><strong>2.\u670d\u52a1\u62a5\u9519<\/strong><br \/>\n<img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/01\/16418964567055.jpg\" alt=\"\"><\/p>\n<p>\u7ecf\u641c\u7d22\u627e\u5230\u4e86\u95ee\u9898\u7b54\u6848\uff1a<\/p>\n<p><a href=\"https:\/\/www.jianshu.com\/p\/222274188e81\" target=\"_blank\" rel=\"noopener\">https:\/\/www.jianshu.com\/p\/222274188e81<\/a><\/p>\n<p>Python \u4ee3\u7801\u6dfb\u52a0\u4e0b\u9762\u7ea2\u8272\u6846\u5c31\u884c\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/01\/16418966124273.jpg\" alt=\"\"><\/p>\n<p>\u4e4b\u540e\u518d\u6267\u884c\uff1a<\/p>\n<pre><code class=\"language-plain_text\">docker-compose up\n<\/code><\/pre>\n<p>\u542f\u52a8\u6210\u529f\uff1a<br \/>\n<img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/01\/16418967965083.jpg\" alt=\"\"><\/p>\n<p>\u8bbf\u95ee\u9875\u9762\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/01\/16418968169304.jpg\" alt=\"\"><\/p>\n<p>\u5237\u65b0\u6570\u5b57\u4f1a\u9012\u589e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b98\u65b9\u7ed9\u4e86\u4e00\u4e2a Docker Compose \u7684\u5c0f\u6848\u4f8b\uff1a https:\/\/docs.docker.co&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":670,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,3],"tags":[36],"class_list":["post-672","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-backend","category-tech","tag-docker"],"_links":{"self":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=672"}],"version-history":[{"count":2,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/672\/revisions"}],"predecessor-version":[{"id":688,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/672\/revisions\/688"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/media\/670"}],"wp:attachment":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}