在 macOS 中搭建独立 Linux 开发环境(OrbStack)
OrbStack 是 macOS 上轻量级的 Linux 虚拟机和 Docker 容器管理工具,比 Docker Desktop 更快更省资源。
安装 OrbStack
# 使用 Homebrew 安装
brew install orbstack
# 或从官网下载:https://orbstack.dev
创建 Linux 虚拟机
# 创建默认 Ubuntu 虚拟机
orbctl create ubuntu
# 查看虚拟机列表
orbctl list
# 进入虚拟机
orb ubuntu
# 停止虚拟机
orbctl stop ubuntu
从外部主机访问
在 Linux 虚拟机中安装并配置 SSH 服务:
# 安装 SSH 服务
sudo apt update && sudo apt install openssh-server
# 配置 SSH
sudo bash -c 'cat > /etc/ssh/sshd_config.d/my.conf << EOF
Port 2222
PasswordAuthentication yes
EOF'
# 重启 SSH 服务
sudo systemctl restart sshd
从 macOS 连接:
ssh username@orb@ubuntu
# 或使用端口
ssh -p 2222 username@localhost
OrbStack 优势
- 启动速度快(约 1 秒)
- 内存占用低
- 与 macOS 深度集成(共享文件系统、网络)
- 支持 x86 和 ARM 架构
- 无缝 Docker 容器管理
原文链接:https://www.ssssmy.com/notes/zai-macos-zhong-da-jian-du-li-linux-kai-fa-huan-jing-orbstack