[需要root],在手機裡安裝chroot系統——使用container2
阿新 • • 發佈:2022-05-10
container2的程式碼目前在termux-container中,是我繼termux-container後寫作的船新版本,風格大不相同,採用tuna源自動獲取rootfs下載連結,不過由於我太懶,此功能未被合併到termux-container中。
此指令碼採用更少的程式碼,更精簡的依賴,docker-like的命令列風格,如果嫌麻煩可以使用我的上一篇部落格中的container-helper,一鍵安裝,更加方便。
安裝:
pkg install curl bash -c "$(curl -L https://raw.githubusercontent.com/Moe-hacker/termux-container/main/container2)"
用法:
container [命令] [選項] [引數]
命令(前面記得加container):
rootfs [ls/rm/pull/search] #管理rootfs ls #列出本地rootfs rm [系統:版本] #刪除一個rootfs pull [系統:版本] #從伺服器下載rootfs search [系統] #查詢rootfs rm [容器] #刪除一個容器 start [容器] #啟動一個容器 stop [容器] #停止一個容器 attach [容器] #連線到一個容器 exec [容器] [命令] #在容器中執行命令,必須使用絕對路徑並使用雙引號 create [容器] [系統:版本] #建立一個容器 ls #列出容器 export [容器] [檔案] #匯出容器為rootfs import [rootfs檔案] [系統:版本] #匯入rootfs save [容器名] [檔案]#儲存一個容器為tar檔案 load [檔案]#從檔案載入容器 help #顯示幫助資訊
示例如下:
#下載alpine edge rootfs: container2 rootfs pull alpine:edge #刪除alpine edge rootfs: container2 rootfs rm alpine:edge #查詢 alpine rootfs container2 rootfs search alpine #建立一個執行alpine edge系統, 名為alpine的容器: container2 create alpine alpine:edge #連線到alpine容器: container2 attach alpine #在容器alpine中執行/bin/sh: container2 exec alpine "/bin/sh" #匯出容器alpine為alpine.tar.xz: container2 export alpine alpine.tar.xz #匯入alpine.tar.xz 為 alpine:myalpine: container2 import alpine.tar.xz alpine:myalpine #儲存容器alpine為alpine.tar: container2 save alpine alpine.tar #從alpine.tar載入容器: container2 load alpine.tar
和docker命令基本類似,是不是非常簡單!
教程完畢!