{"id":244887,"date":"2022-06-24T08:33:37","date_gmt":"2022-06-24T00:33:37","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=244887"},"modified":"2022-06-13T10:35:03","modified_gmt":"2022-06-13T02:35:03","slug":"using-docker-on-a-mac","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/using-docker-on-a-mac.html","title":{"rendered":"Mac\u4e0aDocker\u7684\u4f7f\u7528"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u9996\u5148\u8981\u660e\u786e\u7684\u662f, \u4f5c\u4e3a\u4e00\u4e2a\u6bcf\u5929\u5728 Linux Server \u4e0a rm -rf \u7684\u4eba\u6765\u8bf4, \u5982\u679c\u60f3\u5728 Mac \u4e0a\u4f7f\u7528 Docker, \u6700\u8212\u670d\u7684\u4e5f\u662f\u517c\u5bb9\u6240\u6709 docker cli \u547d\u4ee4\u884c\u64cd\u4f5c\u5373\u53ef\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4e00\u3001\u76ee\u6807\u4efb\u52a1<\/strong><\/div>\n

\u81f3\u4e8e\u56fe\u5f62\u5316\u7684\u754c\u9762\u5b8c\u5168\u4e0d\u9700\u8981, \u6211\u4eec\u5e76\u4e0d\u6307\u671b\u56fe\u5f62\u5316\u754c\u9762\u80fd\u6bd4\u6572\u547d\u4ee4\u5feb\u5230\u54ea\u91cc\u53bb, \u4e5f\u4e0d\u6307\u671b\u56fe\u5f62\u5316\u754c\u9762\u53d8\u4e3a\u4e3b\u529b; \u6240\u4ee5\u672c\u7bc7\u6587\u7ae0\u7684\u6838\u5fc3\u76ee\u6807:<\/p>\n

    \u5728 Mac \u4e0a\u4f7f\u7528\u5b8c\u6574\u7684 docker cli \u547d\u4ee4, \u5305\u62ec\u5bf9\u57fa\u672c\u7684 -v \u6302\u8f7d\u652f\u6301<\/ol>\n
      \u53ef\u4ee5\u652f\u6301 x86 \u7684\u6a21\u62df, \u53ef\u4ee5\u4e3a x86 build \u6216\u8005\u8fd0\u884c\u76f8\u5173\u955c\u50cf<\/ol>\n
        \u5728\u5c3d\u53ef\u80fd\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u8fdb\u884c CPU \u67b6\u6784\u5207\u6362, arm64 \u4e0e x86 \u6700\u597d\u90fd\u53ef\u4ee5\u652f\u6301<\/ol>\n
        \u4e8c\u3001\u5de5\u5177\u9009\u578b<\/strong><\/div>\n

        \u9996\u5148\u662f\u6211\u4eec\u6700\u719f\u6089\u7684 Docker Desktop, \u5b89\u88c5\u5305\u5947\u5927\u65e0\u6bd4, UI \u5361\u6210\u7fd4, \u542f\u52a8\u901f\u5ea6\u66f4\u4e0d\u7528\u63d0\u800c\u4e14\u8fd8\u65f6\u4e0d\u65f6\u7684\u5361\u6b7b, \u6240\u4ee5 Docker Desktop \u662f\u5b8c\u5168\u4e0d\u8003\u8651\u7684; \u90a3\u4e48\u5269\u4e0b\u51e0\u79cd\u65b9\u6848\u7c7b\u578b\u5982\u4e0b:<\/p>\n

          VM \u865a\u62df\u673a\u65b9\u6848<\/ol>\n
            Colima \u65b9\u6848<\/ol>\n
              Lima \u65b9\u6848<\/ol>\n

              \u5148\u8bf4\u7ed3\u8bba: Lima YES! VM \u865a\u62df\u673a\u65b9\u6848\u8981\u82b1\u94b1\u4e14\u96be\u53d7, Colima \u6682\u4e14\u4e0d\u7a33\u5b9a. Lima \u65b9\u6848\u76f4\u63a5\u770b\u7b2c\u4e94\u8282.<\/p>\n

              \u4e09\u3001\u865a\u62df\u673a\u65b9\u6848<\/strong><\/div>\n

              \u76ee\u524d\u5728 M1 \u4e0a, \u552f\u4e00\u53ef\u7528\u6216\u8005\u8bf4\u582a\u7528\u7684\u865a\u62df\u673a\u5f53\u5c5e Parallels Desktop, \u81f3\u4e8e\u5176\u4ed6\u7684 VBox\u3001VMware \u76ee\u524d\u8fd8\u4e0d\u6210\u719f; \u5982\u679c\u7eaf qemu \u6709\u70b9\u8fc7\u4e8e\u786c\u6838(\u613f\u610f\u81ea\u5df1\u5c01\u88c5\u811a\u672c\u7684\u5f53\u6211\u6ca1\u8bf4); \u5bf9\u4e8e Parallels Desktop \u6765\u8bf4, \u6211\u4eec\u9700\u8981\u8d2d\u4e70\u5f00\u53d1\u7248\u672c\u7684 License, \u56e0\u4e3a\u6211\u4eec\u9700\u8981\u501f\u52a9 prlctl \u6765\u5b9e\u73b0\u4e00\u4e9b\u81ea\u52a8\u5316 , \u4e00\u5e74\u597d\u51e0\u767e\u2026 \u7ecf\u8fc7\u6d4b\u8bd5\u8fd9\u79cd\u65b9\u6848\u4e5f\u6709\u4e00\u5b9a\u53ef\u884c\u6027:<\/p>\n

                1\u3001\u9996\u5148\u901a\u8fc7 PD \u521b\u5efa Ubuntu \u4e4b\u7c7b\u7684\u865a\u62df\u673a<\/ol>\n
                  2\u3001\u5728\u865a\u62df\u673a\u91cc\u5b89\u88c5\u597d Docker<\/ol>\n
                    3\u3001\u901a\u8fc7 cli \u7a0b\u5e8f\u542f\u52a8\u865a\u62df\u673a, \u5e76\u4e14\u5c06 ~ rw \u6302\u8f7d\u5230\u865a\u62df\u673a\u91cc<\/ol>\n

                    \u57fa\u4e8e\u8fd9\u4e2a\u65b9\u6848\u6211\u4e2a\u4eba\u5c1d\u8bd5\u8fc7, \u66fe\u7ecf\u5199\u8fc7\u4e00\u4e2a PD \u7684\u5c0f\u5de5\u5177\u6765\u8f85\u52a9\u5b8c\u6210\u6302\u8f7d\u52a8\u4f5c. \u4f46\u662f\u8fd9\u79cd\u5de5\u5177\u6709\u4e00\u4e9b\u660e\u663e\u7684\u7f3a\u70b9:<\/p>\n

                    \u76ee\u524d\u4e0d\u652f\u6301 x86 \u7684\u6a21\u62df, \u53ef\u901a\u8fc7 binfmt \u7f13\u89e3, \u4f46\u662f\u4e0d\u5b8c\u5584\u3002\u865a\u62df\u673a\u8981\u82b1\u94b1\u4e14\u9700\u8981\u865a\u62df\u673a cli \u652f\u6301\u5b8c\u5584<\/p>\n

                    \u56db\u3001Colima \u65b9\u6848<\/strong><\/div>\n

                    Colima \u53f7\u79f0\u662f\u4e13\u95e8\u4e3a\u4e86\u89e3\u51b3 Mac \u5e73\u53f0\u5bb9\u5668\u5316\u5de5\u5177\u94fe\u7684, \u4f46\u662f\u5b9e\u9645\u6d4b\u8bd5\u53d1\u73b0\u76ee\u524d Colima \u8fd8\u4e0d\u7b97\u7a33\u5b9a, \u6709\u65f6\u53ef\u80fd\u4f1a\u6709\u4e00\u4e9b\u5c0f\u95ee\u9898; \u5f53\u7136 Colima \u6700\u5927\u7684\u95ee\u9898\u662f: \u53ef\u81ea\u5b9a\u4e49\u5316\u7a0b\u5ea6\u4e0d\u9ad8, \u5e95\u5c42\u57fa\u4e8e Lima. Colima \u5177\u4f53\u7684\u4f7f\u7528\u65b9\u5f0f\u5565\u7684\u8fd9\u91cc\u6682\u4e0d\u8be6\u7ec6\u63cf\u8ff0, \u76ee\u524d\u8fd8\u4e0d\u7a33\u5b9a\u4e0d\u592a\u63a8\u8350.<\/p>\n

                    \u4e94\u3001Lima \u65b9\u6848<\/strong><\/div>\n

                    Lima \u76ee\u524d\u662f\u57fa\u4e8e QEMU \u7684\u81ea\u52a8\u5316 VM \u65b9\u6848, \u5f53\u524d\u7531\u4e8e\u5176\u51fa\u8272\u8bbe\u8ba1, \u501f\u52a9 Cloud Init \u53ef\u4ee5\u5728\u5f88\u591a\u9636\u6bb5\u5e2e\u52a9\u6211\u4eec\u5b8c\u6210 hook; \u6240\u4ee5\u4e0d\u8bba\u662f\u88c5\u4e2a Docker \u8fd8\u662f k8s, \u4ea6\u6216\u662f\u5f04\u4e2a\u5176\u4ed6\u7684\u4e1c\u897f\u90fd\u5f88\u65b9\u4fbf; \u800c\u4e14\u5f88\u591a\u65b9\u6848\u6bd4\u5982 docker \u5b98\u65b9\u90fd\u6709\u76f8\u5173\u6837\u4f8b, \u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u7167\u6284\u5916\u52a0\u505a\u70b9\u81ea\u5b9a\u4e49.<\/p>\n

                    5.1\u3001Lima \u5b89\u88c5<\/strong><\/span><\/div>\n

                    Lima \u5728 Mac \u4e0b\u5b89\u88c5\u76f8\u5bf9\u7b80\u5355, \u4ee5\u4e0b\u547d\u4ee4\u5c06\u5b89\u88c5 master \u5206\u652f\u7248\u672c.<\/p>\n

                    \r\nbrew install lima --HEADCopy\r\n<\/pre>\n

                    \u5728\u6b63\u5e38\u60c5\u51b5\u4e0b, \u5b89\u88c5 Lima \u4f1a\u9644\u5e26\u5b89\u88c5 QEMU, \u5982\u679c\u672c\u673a\u5df2\u7ecf\u5b89\u88c5 QEMU, \u53ef\u80fd\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5c06 QEMU \u5347\u7ea7\u5230 7.0:<\/p>\n

                    \r\nbrew upgrade qemuCopy\r\n<\/pre>\n

                    \u4e3a\u4e86\u4f7f\u7528 docker, \u8fd8\u9700\u8981\u901a\u8fc7 brew \u5b89\u88c5\u4e00\u4e0b docker cli:<\/p>\n

                    \r\nbrew install dockerCopy\r\n<\/pre>\n
                    5.2\u3001Lima \u4f7f\u7528<\/strong><\/span><\/div>\n

                    \u9ed8\u8ba4\u60c5\u51b5\u4e0b Lima \u5b89\u88c5\u5b8c\u6210\u540e\u4f1a\u751f\u6210\u4e00\u4e2a lima \u7684\u5feb\u6377\u547d\u4ee4, \u76ee\u524d\u4e0d\u592a\u63a8\u8350\u4f7f\u7528, \u539f\u56e0\u662f\u770b\u8d77\u6765\u65b9\u4fbf\u4e00\u70b9\u4f46\u662f\u6ca1\u6cd5\u63a7\u5236\u592a\u591a\u53c2\u6570, \u6240\u4ee5\u4ecd\u7136\u5efa\u8bae\u4f7f\u7528\u6807\u51c6\u7684 limactl \u547d\u4ee4\u8fdb\u884c\u64cd\u4f5c. limactl \u4f7f\u7528\u65b9\u5f0f\u5982\u4e0b:<\/p>\n

                    \r\nLima: Linux virtual machines\r\nUsage:\r\n limactl [command]\r\nExamples:\r\n Start the default instance:\r\n $ limactl start\r\n Open a shell:\r\n $ lima\r\n Run a container:\r\n $ lima nerdctl run -d --name nginx -p 8080:80 nginx:alpine\r\n Stop the default instance:\r\n $ limactl stop\r\n See also example YAMLs: \/opt\/homebrew\/share\/doc\/lima\/examples\r\nAvailable Commands:\r\n completion    Generate the autocompletion script for the specified shell\r\n copy          Copy files between host and guest\r\n delete        Delete an instance of Lima.\r\n edit          Edit an instance of Lima\r\n factory-reset Factory reset an instance of Lima\r\n help          Help about any command\r\n info          Show diagnostic information\r\n list          List instances of Lima.\r\n prune         Prune garbage objects\r\n shell         Execute shell in Lima\r\n show-ssh      Show the ssh command line\r\n start         Start an instance of Lima\r\n stop          Stop an instance\r\n sudoers       Generate \/etc\/sudoers.d\/lima file for enabling vmnet.framework support\r\n validate      Validate YAML files\r\nFlags:\r\n     --debug     debug mode\r\n -h, --help      help for limactl\r\n -v, --version   version for limactl\r\nUse \"limactl [command] --help\" for more information about a command.Copy\r\n<\/pre>\n
                    5.3\u3001Lima \u914d\u7f6e\u6587\u4ef6<\/strong><\/span><\/div>\n

                    Lima \u901a\u8fc7\u8bfb\u53d6\u4e00\u4e2a yaml \u914d\u7f6e\u63cf\u8ff0\u6587\u4ef6\u6765\u51b3\u5b9a\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u673a, \u8be5\u6587\u4ef6\u57fa\u672c\u7ed3\u6784\u5982\u4e0b:<\/p>\n

                    \r\n# \u5b9a\u4e49\u6bcf\u4e2a\u5e73\u53f0\u67b6\u6784\u9700\u8981\u4f7f\u7528\u7684\u542f\u52a8\u955c\u50cf\r\nimages:\r\n- location: \"https:\/\/cloud-images.ubuntu.com\/releases\/22.04\/release\/ubuntu-22.04-server-cloudimg-amd64.img\"\r\n arch: \"x86_64\"\r\n- location: \"https:\/\/cloud-images.ubuntu.com\/releases\/22.04\/release\/ubuntu-22.04-server-cloudimg-arm64.img\"\r\n arch: \"aarch64\"\r\n# \u5b9a\u4e49\u865a\u62df\u673a\u9700\u8981\u4f7f\u7528\u54ea\u4e2a\u67b6\u6784\u542f\u52a8(\u5bf9\u5e94\u4e0a\u9762\u7684\u955c\u50cf)\r\narch: \"x86_64\"\r\n# CPU \u6570\u91cf\r\ncpus: 4\r\n# \u5185\u5b58\u5927\u5c0f\r\nmemory: \"16G\"\r\n# \u78c1\u76d8\u5927\u5c0f\r\ndisk: \"100G\"\r\n# \u865a\u62df\u673a\u4e0e macOS \u5bbf\u4e3b\u673a\u6302\u8f7d\u65f6\u4f7f\u7528\u7684\u6302\u8f7d\u6280\u672f\r\n# \u76ee\u524d\u63a8\u8350 9p, \u53ef\u6362\u6210 sshfs, \u4f46\u662f sshfs \u4f1a\u6709\u6743\u9650\u95ee\u9898\r\nmountType: 9p\r\n# \u5b9a\u4e49\u865a\u62df\u673a\u548c macOS \u5bbf\u4e3b\u673a\u6709\u54ea\u4e9b\u76ee\u5f55\u53ef\u4ee5\u5171\u4eab\r\nmounts:\r\n- location: \"~\"\r\n # \u5b9a\u4e49\u865a\u62df\u673a\u5bf9\u8fd9\u4e2a\u76ee\u5f55\u662f\u5426\u53ef\u5199\r\n writable: true\r\n 9p:\r\n   # \u5bf9\u4e8e\u53ef\u5199\u7684\u5171\u4eab\u76ee\u5f55, cache \u63a8\u8350\u7c7b\u578b\u4e3a mmap, \u4e0d\u5199\u597d\u50cf\u9ed8\u8ba4 fscache\r\n   cache: \"mmap\"\r\n- location: \"\/tmp\/lima\"\r\n writable: true\r\n 9p:\r\n   cache: \"mmap\"\r\n# containerd is managed by Docker, not by Lima, so the values are set to false here.\r\ncontainerd:\r\n system: false\r\n user: false\r\n# cloud-init hook \u5b9a\u4e49\r\nprovision:\r\n# \u5b9a\u4e49\u4ee5\u4ec0\u4e48\u6743\u9650\u5728\u865a\u62df\u673a\u5185\u6267\u884c\u811a\u672c\r\n- mode: system\r\n # This script defines the host.docker.internal hostname when hostResolver is disabled.\r\n # It is also needed for lima 0.8.2 and earlier, which does not support hostResolver.hosts.\r\n # Names defined in \/etc\/hosts inside the VM are not resolved inside containers when\r\n # using the hostResolver; use hostResolver.hosts instead (requires lima 0.8.3 or later).\r\n script: |\r\n   #!\/bin\/sh\r\n   sed -i 's\/host.lima.internal.*\/host.lima.internal host.docker.internal\/' \/etc\/hosts\r\n- mode: system\r\n script: |\r\n   #!\/bin\/bash\r\n   set -eux -o pipefail\r\n   if command -v docker >\/dev\/null 2>&1; then\r\n     docker run --platform=linux\/amd64 --privileged --rm tonistiigi\/binfmt --install all\r\n     exit 0\r\n   else\r\n     export DEBIAN_FRONTEND=noninteractive\r\n     curl -fsSL https:\/\/get.docker.com | sh\r\n     docker run --platform=linux\/amd64 --privileged --rm tonistiigi\/binfmt --install all\r\n     # NOTE: you may remove the lines below, if you prefer to use rootful docker, not rootless\r\n     systemctl disable --now docker\r\n     apt-get install -y uidmap dbus-user-session\r\n   fi\r\n- mode: user\r\n script: |\r\n   #!\/bin\/bash\r\n   set -eux -o pipefail\r\n   systemctl --user start dbus\r\n   dockerd-rootless-setuptool.sh install\r\n   docker context use rootless\r\nprobes:\r\n- script: |\r\n   #!\/bin\/bash\r\n   set -eux -o pipefail\r\n   if ! timeout 30s bash -c \"until command -v docker >\/dev\/null 2>&1; do sleep 3; done\"; then\r\n     echo >&2 \"docker is not installed yet\"\r\n     exit 1\r\n   fi\r\n   if ! timeout 30s bash -c \"until pgrep rootlesskit; do sleep 3; done\"; then\r\n     echo >&2 \"rootlesskit (used by rootless docker) is not running\"\r\n     exit 1\r\n   fi\r\n hint: See \"\/var\/log\/cloud-init-output.log\". in the guest\r\nhostResolver:\r\n # hostResolver.hosts requires lima 0.8.3 or later. Names defined here will also\r\n # resolve inside containers, and not just inside the VM itself.\r\n hosts:\r\n   host.docker.internal: host.lima.internal\r\nportForwards:\r\n- guestSocket: \"\/run\/user\/{{.UID}}\/docker.sock\"\r\n hostSocket: \"{{.Dir}}\/sock\/docker.sock\"\r\n# \u81ea\u5df1\u5b9a\u4e49\u7684\u542f\u52a8\u540e\u6d88\u606f\u8f93\u51fa\r\nmessage: |\r\n To run `docker` on the host (assumes docker-cli is installed), run the following commands:\r\n ------\r\n docker context create amd64 --docker \"host=unix:\/\/{{.Dir}}\/sock\/docker.sock\"\r\n docker context use amd64\r\n ------\r\n<\/pre>\n
                    5.4\u3001\u542f\u52a8 VM<\/strong><\/span><\/div>\n

                    limactl \u547d\u4ee4\u63d0\u4f9b\u4e86\u4e00\u4e2a start \u5b50\u547d\u4ee4\u7528\u4e8e\u542f\u52a8\u4e00\u4e2a\u865a\u62df\u673a, \u5b50\u547d\u4ee4\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570, \u8fd9\u4e2a\u53c2\u6570\u5f62\u5f0f\u4e0d\u540c\u4f1a\u4ea7\u751f\u4e0d\u540c\u7684\u884c\u4e3a:<\/p>\n

                      \u5982\u679c\u53c2\u6570\u4e3a\u4e00\u4e2a\u6587\u4ef6\u8def\u5f84, \u5219\u5047\u5b9a\u6587\u4ef6\u4e3a\u4e00\u4e2a lima \u865a\u62df\u673a\u7684 yaml \u914d\u7f6e, \u8bfb\u53d6\u5e76\u542f\u52a8<\/ol>\n
                        \u5982\u679c\u53c2\u6570\u662f\u5355\u7eaf\u5b57\u7b26\u4e32, \u9996\u5148\u5c1d\u8bd5\u4ece\u5df2\u5b58\u5728\u7684\u865a\u62df\u673a\u4e2d\u67e5\u627e\u540d\u5b57\u76f8\u540c\u7684, \u627e\u5230\u5219\u7acb\u5373\u542f\u52a8<\/ol>\n
                          \u5982\u679c\u53c2\u6570\u662f\u5355\u7eaf\u5b57\u7b26\u4e32, \u4e14\u672a\u627e\u5230\u5df2\u5b58\u5728\u540c\u540d\u7684\u865a\u62df\u673a, \u5219\u5c1d\u8bd5\u901a\u8fc7\u5185\u7f6e\u6a21\u7248\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u673a<\/ol>\n

                          \u4ee5\u4e0a\u9762\u6211\u81ea\u5df1\u5b9a\u4e49\u7684 docker \u914d\u7f6e\u6587\u4ef6\u4e3a\u4f8b, \u6211\u4eec\u76f4\u63a5\u542f\u52a8\u8fd9\u4e2a\u914d\u7f6e\u65e2\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a docker \u865a\u62df\u673a:<\/p>\n

                          \r\nlimactl start .\/docker-amd64.yamlCopy\r\n<\/pre>\n

                          \u542f\u52a8\u540e\u4f1a\u63d0\u793a\u662f\u5426\u7f16\u8f91\u7136\u540e\u518d\u542f\u52a8, \u8fd9\u662f\u4e3a\u4e86\u4f7f\u7528\u540c\u4e00\u4e2a\u914d\u7f6e\u6765\u542f\u52a8\u591a\u4e2a vm \u4f7f\u7528\u7684, \u6240\u4ee5\u4e0d\u7f16\u8f91\u76f4\u63a5\u542f\u52a8\u5373\u53ef:<\/p>\n

                          \"\"<\/p>\n

                          \u7a0d\u7b49\u7247\u523b\u540e\u865a\u62df\u673a\u5c06\u542f\u52a8\u6210\u529f:<\/p>\n

                          \"\"<\/p>\n

                          \u542f\u52a8\u5b8c\u6210\u540e, \u6267\u884c\u6700\u4e0b\u9762\u6253\u5370\u51fa\u7684\u4e24\u6761\u547d\u4ee4, \u5373\u53ef\u5728\u5bbf\u4e3b\u673a\u4e0a\u5b8c\u6574\u7684\u4f7f\u7528 docker. \u5176\u672c\u8d28\u4e0a\u5229\u7528 docker context \u529f\u80fd, \u7136\u540e\u901a\u8fc7\u5c06\u865a\u62df\u673a\u4e2d\u7684 sock \u6587\u4ef6\u6302\u8f7d\u5230\u5bbf\u4e3b\u673a, \u5e76\u914d\u7f6e docker context \u6765\u5b9e\u73b0\u65e0\u7f1d\u4f7f\u7528 docker \u547d\u4ee4.<\/p>\n

                          5.5\u3001\u865a\u62df\u673a\u8c03\u6574<\/strong><\/span><\/div>\n

                          \u67d0\u4e9b\u60c5\u51b5\u4e0b, \u6211\u4eec\u9700\u8981\u5b9a\u5236\u4e00\u4e9b VM \u91cc\u7684\u914d\u7f6e, \u5728\u5b9a\u5236\u65f6\u4e3b\u8981\u9700\u8981\u8c03\u6574\u914d\u7f6e\u6587\u4ef6\u7684 provision \u90e8\u5206; \u5728\u8be5\u90e8\u5206\u4e2d, \u5982\u679c mode \u88ab\u5b9a\u4e49\u4e3a system \u5219\u4f1a\u4ee5 root \u7528\u6237\u6267\u884c\u76f8\u5173\u547d\u4ee4, \u5426\u5219\u4ee5\u666e\u901a\u7528\u6237\u6765\u6267\u884c\u547d\u4ee4. \u9700\u8981\u6ce8\u610f\u7684\u662f, \u6211\u4eec\u5b9a\u4e49\u7684\u811a\u672c\u9700\u8981\u5177\u6709\u5e42\u7b49\u6027, \u56e0\u4e3a\u811a\u672c\u5728\u6bcf\u6b21\u90fd\u4f1a\u6267\u884c\u4e00\u6b21, \u6240\u4ee5\u4e00\u822c\u5bf9\u4e8e\u53ef\u80fd\u9020\u6210\u6570\u636e\u64e6\u9664\u52a8\u4f5c\u7684\u547d\u4ee4\u90fd\u8981\u5199\u597d\u5224\u65ad\u903b\u8f91, \u907f\u514d\u91cd\u590d\u6267\u884c.<\/p>\n

                          \u5173\u4e8e\u6587\u4ef6\u6302\u8f7d, \u8fd9\u91cc\u63a8\u8350\u4f7f\u7528 9p \u7c7b\u578b, \u672a\u6765 lima \u5c06\u5b8c\u5168\u5207\u6362\u5230\u8be5\u6302\u8f7d\u65b9\u5f0f; \u540c\u65f6\u7ecf\u8fc7\u6d4b\u8bd5\u76ee\u524d\u4ec5\u6709 9p \u6302\u8f7d\u6a21\u5f0f\u4e0b, \u672c\u5730\u76ee\u5f55 rw \u6620\u5c04\u5230\u865a\u62df\u673a\u65f6\u4e0d\u4f1a\u51fa\u73b0\u6743\u9650\u95ee\u9898, sshfs \u65b9\u5f0f\u6302\u8f7d\u5982\u679c\u9047\u5230 chown \u4e4b\u7c7b\u7684\u547d\u4ee4\u4f1a\u9020\u6210\u6743\u9650\u9519\u8bef, \u53ef\u80fd\u5bfc\u81f4\u5bb9\u5668\u542f\u52a8\u5931\u8d25(\u4f8b\u5982 mysql).<\/p>\n

                          \u5728\u6d4b\u8bd5\u865a\u62df\u673a\u914d\u7f6e\u8fc7\u7a0b\u4e2d, \u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 limactl delete -f xxxx \u6765\u5f3a\u5236\u5220\u9664\u76ee\u6807\u865a\u62df\u673a, \u7136\u540e\u91cd\u65b0\u542f\u52a8\u5373\u53ef; \u865a\u62df\u673a\u540d\u79f0\u9ed8\u8ba4\u4e0e yaml \u6587\u4ef6\u540d\u76f8\u540c, \u53ef\u4f7f\u7528 limactl ls \u547d\u4ee4\u67e5\u770b.<\/p>\n

                          5.6\u3001\u591a\u5e73\u53f0\u517c\u5bb9<\/strong><\/span><\/div>\n

                          \u5728\u4e0a\u9762\u6211\u7684 docker \u914d\u7f6e\u6837\u4f8b\u4e2d, \u6bcf\u6b21\u865a\u62df\u673a\u542f\u52a8\u5b8c\u6210\u540e\u4f1a\u81ea\u52a8\u5b89\u88c5 binfmt:<\/p>\n

                          \r\ndocker run --platform=linux\/amd64 --privileged --rm tonistiigi\/binfmt --install allCopy\r\n<\/pre>\n

                          \u8fd9\u6837\u80fd\u4fdd\u8bc1\u65e0\u8bba Lima \u865a\u62df\u673a\u539f\u59cb\u67b6\u6784\u662f\u4ec0\u4e48, \u90fd\u80fd\u8fd0\u884c\u5176\u4ed6\u5e73\u53f0\u7684 docker \u955c\u50cf; \u5178\u578b\u7684\u4f8b\u5982\u67d0\u4e9b openjdk8 \u955c\u50cf\u53ea\u6709 amd64 \u7684\u7248\u672c, \u4f46\u662f\u5728 lima \u865a\u62df\u673a\u4e3a aarch64 \u7684\u60c5\u51b5\u4e0b\u4ecd\u7136\u53ef\u4ee5\u4f7f\u7528.<\/p>\n

                          \u9664\u4e86\u8fd9\u79cd \u201c\u901f\u5ea6\u8f83\u5feb\u201d \u7684\u8de8\u67b6\u6784\u8fd0\u884c\u65b9\u5f0f, lima \u8fd8\u652f\u6301\u76f4\u63a5\u5728 VM \u4e2d\u5b9a\u4e49\u67b6\u6784, \u8fd9\u6837\u5728 qemu \u542f\u52a8\u65f6\u5219\u4f1a\u76f4\u63a5\u4ece VM \u7cfb\u7edf\u5c42\u6a21\u62df\u76ee\u6807\u67b6\u6784; \u8fd9\u79cd\u65b9\u5f0f\u7684\u597d\u5904\u662f\u5bf9\u76ee\u6807\u67b6\u6784\u517c\u5bb9\u6027\u5f88\u597d, \u4f46\u662f\u8fd0\u884c\u901f\u5ea6\u4f1a\u66f4\u6162. \u8c03\u6574 VM \u67b6\u6784\u53ea\u9700\u8981\u4fee\u6539 arch \u914d\u7f6e\u5373\u53ef(\u6ce8\u610f, \u76ee\u6807\u67b6\u6784\u7684\u955c\u50cf\u4e00\u5b9a\u8981\u914d\u7f6e\u597d):<\/p>\n

                          \r\n# \u5b9a\u4e49\u6bcf\u4e2a\u5e73\u53f0\u67b6\u6784\u9700\u8981\u4f7f\u7528\u7684\u542f\u52a8\u955c\u50cf\r\nimages:\r\n- location: \"https:\/\/cloud-images.ubuntu.com\/releases\/22.04\/release\/ubuntu-22.04-server-cloudimg-amd64.img\"\r\n arch: \"x86_64\"\r\n- location: \"https:\/\/cloud-images.ubuntu.com\/releases\/22.04\/release\/ubuntu-22.04-server-cloudimg-arm64.img\"\r\n arch: \"aarch64\"\r\n# \u5b9a\u4e49\u672c\u865a\u62df\u673a\u9700\u8981\u4f7f\u7528\u54ea\u4e2a\u67b6\u6784\u542f\u52a8(\u5bf9\u5e94\u4f1a\u4f7f\u7528\u4e0a\u9762\u76ee\u6807\u67b6\u6784\u7684\u955c\u50cf)\r\narch: \"aarch64\"Copy\r\n<\/pre>\n
                          \u516d\u3001\u603b\u7ed3<\/strong><\/div>\n

                          \u76ee\u524d\u6574\u4f53\u6765\u770b, Docker Desktop \u5728 mac \u4e0a\u57fa\u672c\u4e0a\u662f\u5f88\u96be\u7528\u7684, Colima \u73b0\u5728\u8fd8\u4e0d\u592a\u6210\u719f, \u9002\u5408\u8f7b\u5ea6\u4f7f\u7528 docker \u7684\u7528\u6237; \u800c\u91cd\u5ea6\u4f7f\u7528 docker \u5e76\u4e14\u6709\u5b9a\u5236\u5316\u9700\u6c42\u7684\u7528\u6237\u8fd8\u662f\u63a8\u8350 Lima \u865a\u62df\u673a; \u540c\u65f6 Lima \u4e5f\u652f\u6301\u5f88\u591a\u64cd\u4f5c\u7cfb\u7edf, \u5b98\u65b9\u6709\u5927\u91cf\u7684\u6837\u4f8b\u6a21\u7248(\u5305\u62ec k8s\u3001k3s\u3001podman \u7b49), \u975e\u5e38\u9002\u5408\u91cd\u5ea6\u5bb9\u5668\u4f7f\u7528\u8005\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

                          \u81f3\u4e8e\u56fe\u5f62\u5316\u7684\u754c\u9762\u5b8c\u5168\u4e0d\u9700\u8981, \u6211\u4eec\u5e76\u4e0d\u6307\u671b\u56fe\u5f62\u5316\u754c\u9762\u80fd\u6bd4\u6572\u547d\u4ee4\u5feb\u5230\u54ea\u91cc\u53bb, \u4e5f\u4e0d\u6307\u671b\u56fe\u5f62\u5316\u754c\u9762\u53d8\u4e3a\u4e3b\u529b; \u6240\u4ee5 […]<\/p>\n","protected":false},"author":1329,"featured_media":244894,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-244887","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/244887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=244887"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/244887\/revisions"}],"predecessor-version":[{"id":244896,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/244887\/revisions\/244896"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/244894"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=244887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=244887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=244887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}