{"id":628,"date":"2026-01-03T18:50:28","date_gmt":"2026-01-03T10:50:28","guid":{"rendered":"https:\/\/note.yuncrown.com\/?p=628"},"modified":"2026-01-03T19:51:06","modified_gmt":"2026-01-03T11:51:06","slug":"%e5%85%89%e4%bc%8f%e8%af%86%e5%88%ab%e7%b3%bb%e7%bb%9fdocker%e5%ae%89%e8%a3%85%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/note.yuncrown.com\/index.php\/2026\/01\/03\/%e5%85%89%e4%bc%8f%e8%af%86%e5%88%ab%e7%b3%bb%e7%bb%9fdocker%e5%ae%89%e8%a3%85%e6%ad%a5%e9%aa%a4\/","title":{"rendered":"\u5149\u4f0f\u8bc6\u522b\u7cfb\u7edfdocker\u5b89\u88c5\u6b65\u9aa4"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u521b\u5efa\u6587\u4ef6\u5939<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ~\nmkdir -p docker\/nginx docker\/mysql docker\/code\nmkdir -p vision<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u521b\u5efadocker-compose.yml\u76ee\u5f55<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>services:\n  mysql:\n    image: mysql:8.0\n    container_name: mysql8\n    restart: unless-stopped\n    environment:\n      MYSQL_ROOT_PASSWORD: 08129d06979d09de\n      MYSQL_DATABASE: db_vision\n      MYSQL_USER: vision\n      MYSQL_PASSWORD: FrJn2WJrhzAfExYA\n    ports:\n      - \"3306:3306\"\n    volumes:\n      - .\/mysql\/data:\/var\/lib\/mysql\n\n  django:\n    image: python:3.12\n    container_name: python312\n    restart: unless-stopped\n    working_dir: \/code\/vision   # \u6539\u6210\u9879\u76ee\u6839\u76ee\u5f55\n    volumes:\n      - .\/code\/vision:\/code\/vision\n      - \/vision:\/vision        # \u4e0a\u4f20\/\u751f\u6210\u6587\u4ef6\n    command: bash -c \"pip install --upgrade pip &amp;&amp; pip install -r requirements.txt &amp;&amp; python manage.py runserver 0.0.0.0:8000\"\n    ports:\n      - \"8000:8000\"\n    environment:\n      - PYTHONUNBUFFERED=1\n    depends_on:\n      - mysql<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u521b\u5efadockerfile\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 1. \u57fa\u7840\u955c\u50cf\nFROM python:3.12-slim\n\n# 2. \u5de5\u4f5c\u76ee\u5f55\nWORKDIR \/app\n\n# 3. \u590d\u5236\u4f9d\u8d56\u6587\u4ef6\nCOPY code\/vision\/requirements.txt .\n\n# 4. \u5b89\u88c5\u4f9d\u8d56\nRUN pip install --upgrade pip &amp;&amp; \\\n    pip install --no-cache-dir -r requirements.txt\n\n# 5. \u9ed8\u8ba4\u547d\u4ee4\nCMD &#91;\"bash\"]\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u521b\u5efamysql8.0\u7684\u6570\u636e\u76ee\u5f55<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u8fdb\u5165 mysql \u76ee\u5f55\ncd ~\/docker\/mysql\n# \u521b\u5efa MySQL \u6570\u636e\u76ee\u5f55\nmkdir -p data<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u542f\u52a8\/\u505c\u6b62\u547d\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u542f\u52a8\u5bb9\u5668\uff0c\u7b2c\u4e00\u6b21\u5982\u679c\u6ca1\u6709\u955c\u50cf\u4f1a\u81ea\u52a8\u4e0b\u8f7d\ndocker compose up -d<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u521b\u5efa\u6587\u4ef6\u5939 \u521b\u5efadocker-compose.yml\u76ee\u5f55 \u521b\u5efadockerfile\u6587\u4ef6 \u521b\u5efamysql8.0\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-628","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/note.yuncrown.com\/index.php\/wp-json\/wp\/v2\/posts\/628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/note.yuncrown.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/note.yuncrown.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/note.yuncrown.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/note.yuncrown.com\/index.php\/wp-json\/wp\/v2\/comments?post=628"}],"version-history":[{"count":8,"href":"https:\/\/note.yuncrown.com\/index.php\/wp-json\/wp\/v2\/posts\/628\/revisions"}],"predecessor-version":[{"id":638,"href":"https:\/\/note.yuncrown.com\/index.php\/wp-json\/wp\/v2\/posts\/628\/revisions\/638"}],"wp:attachment":[{"href":"https:\/\/note.yuncrown.com\/index.php\/wp-json\/wp\/v2\/media?parent=628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/note.yuncrown.com\/index.php\/wp-json\/wp\/v2\/categories?post=628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/note.yuncrown.com\/index.php\/wp-json\/wp\/v2\/tags?post=628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}