接手 link 或環境位址
在較新的箱子上,sandbox_wire 可以把原本經 link 或連接器出去的名字,原地換成箱子裡你的程序或發布好的版本,箱子的網址不變。
在 sandbox_status → health.features 有 take-over 的箱子上(2026-09-25 12:40 UTC 起開的箱子都有,映像 box-202609251946;箱子一直用它開箱時的 boxd,凍結再解凍也一樣),sandbox_wire 可以讓箱子裡的服務用一個現在會連出箱子的名字,不管它是經 link 還是經連接器出去:
sandbox_wire { "id": "<id>", "service": "billing.acme.internal", "port": 8080, "targetPort": 8081 }
sandbox_wire { "id": "<id>", "service": "billing.acme.internal", "port": 8080, "version": "refund-a1b2c3d", "env": { "WORKERS_ENABLED": "false" } }
- 第一種是你自己在
targetPort上的程式;第二種是已發布的版本(照常可帶env與containerPort)。只要那個name:port現在是 link 或環境的位址,兩種都會就地接手這個名字。 - 名字在箱子裡保留原本的位址,所以快取了 DNS 結果的程式照樣連得到;從此它連到箱子裡的
targetPort。 - 經 link 或連接器開著的連線會被關掉;程式重新連線,這次連到箱子裡的那份。
- link 不再是 link:
sandbox_status.services裡的fromBox與fromPort拿掉,另一個箱子的linkedFrom也不再列出這個箱子。箱子的網址不變。 - 接手要在名字連出去的那個 port 上做;換成別的 port 呼叫會失敗:
<name> is reached through the connector or a link on port [<port>]; a name cannot be a service in the box on port <n> and go out on another。名字在好幾個 port 上連出去時(例如環境列了db.internal:5432與db.internal:6432),只接手其中一個也不行:<name> is also reached through the connector or a link on port [<port>]; a name cannot be a service in the box on one port and go out on another。一個名字不能在一個 port 是箱子裡的服務、在另一個 port 又連出去。這種名字改在sandbox_start宣告,在那裡它每個 port 都指到箱子。 - 對 link 的名字切換
mode一律回 409:<name> is a link in this box, which has no box or external mode. Wire it again with fromBox or fromPort to change where it goes, or pass port (and targetPort) to run the service in the box instead。
比較舊的箱子(health.features 裡沒有 take-over):
- link 的名字帶
port回 409<name> is a link in this box, and box <id> runs boxd <version>, which cannot turn a link into a service in the box. Wire it again with fromBox or fromPort to change where it goes, or start a new box that declares the service,帶version回<name> is a link in this box, and box <id> runs boxd <version>, which cannot turn a link into a published version. Start a new box that declares the version, or wire the link again with fromBox or fromPort; - 帶
port或version補上、又是環境位址的名字,照樣經連接器連出去;這種名字要改在sandbox_start宣告。
所有工具與主題都列在工具參考。