Windows VsCode 远程连接Docker中的linux arm64容器开发环境
1、安装好Docker Desktop,并启动Docker服务。
2、在VsCode中安装Remote Development插件。
4、配置Docker Desktop。点击Docker Desktop右上角的“Settings”,选择“General”,将“Expose daemon on tcp://localhost:2375 without TLS”勾选上,并点击“Apply & Restart”。
5、启用QEMU模拟器,可运行任意架构镜像。
bash
docker pull docker.1ms.run/tonistiigi/binfmt
docker run --privileged --name binfmt --restart on-failure:1 docker.1ms.run/tonistiigi/binfmt --install all6、安装Linux arm64镜像。启动命令行,运行以下命令:
bash
docker pull arm64v8/ubuntubash
docker pull --platform linux/arm64 docker.1ms.run/arm64v8/ubuntu:20.04bash
docker pull docker.1ms.run/loongarch64/debian:latest7、执行如下命令,启动容器并把本地所有硬盘挂载到容器mnt目录下:
bash
docker run -v C:/:/mnt/c -v D:/:/mnt/d -v E:/:/mnt/e -v F:/:/mnt/f -v G:/:/mnt/g -it --name linux-arm64 --restart unless-stopped arm64v8/ubuntu /bin/bashbash
docker run -v C:/:/mnt/c -v D:/:/mnt/d -v E:/:/mnt/e -v F:/:/mnt/f -v G:/:/mnt/g -it --name linux-arm64 --restart unless-stopped docker.1ms.run/arm64v8/ubuntu:20.04 /bin/bashbash
docker run -v C:/:/mnt/c -v D:/:/mnt/d -v E:/:/mnt/e -v F:/:/mnt/f -v G:/:/mnt/g -it --name linux-loong64 --restart unless-stopped docker.1ms.run/loongarch64/debian:latest /bin/bash注意:以上命令中的C:/、D:/、E:/、F:/、G:/等是Windows系统盘的盘符,请根据实际情况替换。
8、打开VsCode,点击左侧的远程资源管理器图标,在开发容器中点击右键,选择“在当前窗口中附加”,即可在vsCode中远程连接到Docker中的容器。
9、点击vsCode中的“打开文件夹”,选中/mnt中挂载的本地项目目录,即可开始开发。
10、在VsCode中打开终端,可以安装gcc等工具,并在容器中进行编译、调试等工作。
文档中心