對於開發者與 DevOps 工程師來說,快速建立乾淨且獨立的 Linux 測試環境是日常剛需。
OrbStack 以極輕量與高效能成為取代 Docker Desktop 成為容器化的新秀。
但很多人不知道,其實 OrbStack 可以開一些簡單的 Linux 虛擬機 (Virtual Machine, VM)。
在一些特定的情況下,你可能會需要一層薄薄的沙箱 (Sandbox),
一個「有 root 的工作空間」
如果你剛好用 macOS,也剛好有裝 OrbStack,
OrbStack CLI(orb 指令)的指令可以幫你輕鬆建立與管理 Linux 虛擬機。
這邊就整理一下這些細節,用 orb 指令來管理 OrbStack 內建的虛擬機。
orb 指令說明
這邊列出 orb 指令的說明,後面會跟大家說要怎麼使用
Usage:
orb create [flags] DISTRO[:VERSION] [MACHINE_NAME]
Aliases:
create, add, new
Examples:
orb create -a arm64 ubuntu:24.04
orb create --memory 4G --cpus 2 --disk 64G ubuntu dev
orb create -a amd64 fedora foo
Flags:
-a, --arch string Override the default architecture
--cpus string CPU core limit for the machine
--disk string Disk usage limit for the machine (GiB, or units like 64G)
--forward-ssh-agent Enable SSH agent forwarding for an isolated machine
-h, --help help for create
--isolate-network Block an isolated machine from other machines and host IPs
--isolated Create an isolated machine (disables file sharing and integration)
--memory string Memory limit for the machine (MiB, or units like 4G)
--mount stringArray Add a selective host mount for an isolated machine as SOURCE[:DEST] (repeatable)
-p, --set-password Set a password for the default user
-u, --user string Username for the default user
-c, --user-data string Path to Cloud-init user data file (for automatic setup)
核心指令語法
使用 orb create 即可快速建立新的 Linux 虛擬機器:
orb create [旗標] 發行版[:版本] [機器名稱]
- 別名(Aliases):
create、add、new皆可通用。
常用旗標(Flags)說明
| 旗標 / 參數 | 完整名稱 | 說明 |
|---|---|---|
-a |
--arch |
變更預設架構(例如:arm64 或 amd64) |
--cpus |
設定 CPU 核心數上限 | |
--memory |
設定記憶體上限(例如:4G、2048M) |
|
--disk |
設定磁碟容量上限(例如:64G) |
|
-u |
--user |
指定預設使用者名稱 |
-p |
--set-password |
為預設使用者設定密碼 |
-c |
--user-data |
指定 Cloud-init 寫入檔路徑(用於自動化初始化設定) |
--isolated |
建立隔離機器(關閉檔案共享與系統整合) | |
--isolate-network |
封鎖隔離機器存取其他機器與宿主機 IP | |
--forward-ssh-agent |
為隔離機器啟用 SSH Agent 轉發 | |
--mount |
為隔離機器新增指定的宿主機掛載點(格式:來源[:目標],可重複使用) |
一些快速上手的範例
1. 建立具有 Root 權限的獨立工作空間
若需要一個能隨意使用 sudo 測試安裝套件或準備素材的獨立環境,可以直接指定架構建立:
- 建立 x86 (amd64) 架構的 Ubuntu 虛擬機器
orb create --a amd64 ubuntu
- 進入該虛擬機器(以預設 ubuntu 為例)
orb -m ubuntu
進入之後你會發現提示詞有變化,會不一樣
就像你登入 SSH 一樣
然後就可以在這個環境自由的操作了
2. 其他各種常見的情境
這裏列出其他常見的指令範例,供參考
- 建立最新版 Ubuntu(自動命名)
orb create ubuntu
註:你可以用 tab 鍵去看有哪些發行版可以用,目前只支援 Linux 常見的發行版
官方也明確表示不支援 Windows 虛擬機
這邊我列出目前截稿它有的選項
alma
alma:10
alma:8
alma:9
alpine
alpine:3.21
alpine:3.22
alpine:3.23
alpine:edge
arch
arch:current
centos
centos:10-Stream
centos:9-Stream
debian
debian:10
debian:11
debian:12
debian:13
debian:14
debian:bookworm
debian:bookworm
debian:bullseye
debian:bullseye
debian:buster
debian:forky
debian:forky
debian:trixie
debian:trixie
devuan
devuan:4
devuan:5
devuan:chimaera
devuan:chimaera
devuan:daedalus
devuan:daedalus
devuan:excalibur
fedora
fedora:42
fedora:43
fedora:44
gentoo
gentoo:current
kali
kali:current
nixos
nixos:25.11
nixos:unstable
openeuler
openeuler:22.03
openeuler:24.03
openeuler:25.09
opensuse
opensuse:15.5
opensuse:16.0
opensuse:tumbleweed
oracle
oracle:8
oracle:9
rocky
rocky:10
rocky:8
rocky:9
ubuntu
ubuntu:20.04
ubuntu:22.04
ubuntu:24.04
ubuntu:24.10
ubuntu:25.04
ubuntu:25.10
ubuntu:26.04
ubuntu:focal
ubuntu:jammy
ubuntu:jammy
ubuntu:noble
ubuntu:noble
ubuntu:oracular
ubuntu:plucky
ubuntu:questing
ubuntu:questing
ubuntu:resolute
ubuntu:resolute
void
void:current
- 指定特定版本與自訂名稱:
orb create ubuntu:noble devbox
自訂的名稱叫做 devbox
版本是: Ubuntu 24.04.4 (Noble Numbat)
- 配置硬體資源上限:
orb create --memory 4G --cpus 2 --disk 64G ubuntu dev
- 透過 Rosetta 在 Apple Silicon 上模擬 x86 架構:
orb create --arch amd64 debian x86vm
檔案共享機制
OrbStack 提供非常便利的系統整合功能:預設會自動將 Mac 的 /Users 目錄共享並掛載至 Linux 虛擬機器的相同路徑下。這代表你在 Mac 上的檔案可以直接在虛擬機器內存取,無需額外設定複雜的共享資料夾。
希望這篇文章對你有幫助

