VMware Fusion 12をmacOSにインストールし、vctl
を動かしてみた内容です。
コンテナー起動
$ vctl system start
Preparing storage...
Container storage has been prepared successfully under /Users/shtanaka/.vctl/storage
Launching container runtime...
Container runtime has been started.
$ vctl pull nginx INFO Pulling from index.docker.io/library/nginx:latest ─── ────── ──────── REF STATUS PROGRESS ─── ────── ──────── index-sha256:c628b67d21744fce822d22fdcc0389f6bd763daac23a6b77147d0712ea7102d0 Done 100% (1862/1862) manifest-sha256:794275d96b4ab96eeb954728a7bf11156570e8372ecd5ed0cbc7280313a27d19 Done 100% (1362/1362) layer-sha256:2ee525c5c3ccc83fd7041be26c5b62c5a1c02e7574b33acd99b97bc720b1b96b Done 100% (668/668) layer-sha256:ebd81fc8c07158adaa0b1f8f67efcb24572d81e8bd00c9e6e6c38fb1df262f19 Done 100% (26401303/26401303) config-sha256:7e4d58f0e5f3b60077e9a5d96b4be1b974b5a484f54f9393000a99f3b6816e3d Done 100% (7512/7512) layer-sha256:655316c160af28a73fc28f9d14986607dcc11dd803b58806a6f168faed14dc2c Done 100% (600/600) layer-sha256:d121f8d1c4128ebc1e95e5bfad90a0189b84eadbbb2fbaad20cbb26d20b2c8a2 Done 100% (27092161/27092161) layer-sha256:d15953c0e0f87e413ad2fbf7c251c64276c2c2407effbcbe97c3d7b9a8a36271 Done 100% (899/899) INFO Unpacking nginx:latest... INFO done
$ vctl run -n myNginx -t -d nginx INFO container myNginx started and detached from current session $ vctl ps -a ──── ───── ─────── ── ───── ────── ───────────── NAME IMAGE COMMAND IP PORTS STATUS CREATION TIME ──── ───── ─────── ── ───── ────── ───────────── myNginx nginx:latest /docker-entrypoint.s... 172.16.70.129 n/a running 2020-09-17T15:37:55+09:00
$ vctl describe myNginx Name: myNginx Status: running Command: /docker-entrypoint.sh nginx -g daemon off; Container rootfs in host: /Users/shtanaka/.vctl/storage/containerd/state/io.containerd.runtime.v2.task/vctl/myNginx/rootfs IP address: 172.16.70.129 Creation time: 2020-09-17T15:37:55+09:00 Image name: nginx:latest Image size: 51.0 MiB Host virtual machine: /Users/shtanaka/.vctl/.r/vms/myNginx/myNginx.vmx Container rootfs in VM: /.containers/myNginx Access in host VM: vctl execvm --sh -c myNginx Exec in host VM: vctl execvm -c myNginx /bin/ls
コンテナーの停止
$ vctl stop myNginx
INFO container myNginx has been stopped
停止後、再度起動
$ vctl start myNginx -d INFO container myNginx started and detached from current session
コンテナーイメージ操作
$ vctl images ──── ───────────── ──── NAME CREATION TIME SIZE ──── ───────────── ──── nginx:latest 2020-09-17T15:37:09+09:00 51.0 MiB $ vctl rm myNginx ──── ────── ────── NAME RESULT REASON ──── ────── ────── myNginx REMOVED $ vctl images ──── ───────────── ──── NAME CREATION TIME SIZE ──── ───────────── ──── nginx:latest 2020-09-17T15:37:09+09:00 51.0 MiB $ vctl rmi nginx ──── ────── ────── NAME RESULT REASON ──── ────── ────── nginx:latest REMOVED $ vctl images ──── ───────────── ──── NAME CREATION TIME SIZE ──── ───────────── ────
ホストVMへのログイン
$ vctl execvm --sh -c myNginx sh-4.4# ls -l total 0 drwxr-xr-x 2 201 201 3380 2020-09-17 06:44 bin drw-r--r-- 12 0 0 240 2020-09-17 06:44 cgroup drwxr-xr-x 6 0 0 2080 2020-09-17 06:44 dev drwxr-xr-x 3 201 201 100 2020-09-17 06:44 etc drwxr-xr-x 3 201 201 100 2020-09-17 06:44 lib drwxr-xr-x 2 201 201 760 2020-09-17 06:44 lib64 dr-xr-xr-x 73 0 0 0 2020-09-17 06:44 proc drwxr-xr-x 4 201 201 80 2020-09-17 06:44 rootfs drwxr-xr-x 3 201 201 80 2020-09-17 06:44 run drwxr-xr-x 2 201 201 300 2020-09-17 06:44 sbin dr-xr-xr-x 11 0 0 0 2020-09-17 06:45 sys drwx------ 4 0 0 100 2020-09-17 06:44 tmp drwxr-xr-x 6 201 201 120 2020-09-17 06:44 usr drwxr-xr-x 3 0 0 60 2020-09-17 06:44 var $ vctl execvm -c myNginx /bin/ls bin dev lib proc run sys usr cgroup etc lib64 rootfs sbin tmp var
コンテナーへの実行
$ vctl exec -it myNginx sh # ls bin boot dev docker-entrypoint.d docker-entrypoint.sh etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var # ls -l total 4 drwxr-xr-x 72 root root 2304 Sep 8 07:00 bin drwxr-xr-x 2 root root 64 Jul 10 21:04 boot drwxr-xr-x 5 root root 340 Sep 17 06:44 dev drwxr-xr-x 4 root root 128 Sep 10 12:33 docker-entrypoint.d -rwxrwxr-x 1 root root 1202 Sep 10 12:32 docker-entrypoint.sh drwxr-xr-x 80 root root 2560 Sep 17 06:38 etc drwxr-xr-x 2 root root 64 Jul 10 21:04 home drwxr-xr-x 8 root root 256 Sep 10 12:33 lib drwxr-xr-x 3 root root 96 Sep 8 07:00 lib64 drwxr-xr-x 2 root root 64 Sep 8 07:00 media drwxr-xr-x 2 root root 64 Sep 8 07:00 mnt drwxr-xr-x 2 root root 64 Sep 8 07:00 opt dr-xr-xr-x 72 root root 0 Sep 17 06:44 proc drwx------ 5 root root 160 Sep 17 06:45 root drwxr-xr-x 5 root root 160 Sep 17 06:44 run drwxr-xr-x 66 root root 2112 Sep 8 07:00 sbin drwxr-xr-x 2 root root 64 Sep 8 07:00 srv dr-xr-xr-x 11 root root 0 Sep 17 06:45 sys drwxrwxrwt 2 root root 64 Sep 10 12:33 tmp drwxr-xr-x 10 root root 320 Sep 8 07:00 usr drwxr-xr-x 13 root root 416 Sep 8 07:00 var
vctl run
でエラーが出る場合
$ vctl run -n myNginx -t -d nginx ERROR failed to stop a sandbox, err:error code:exit status 255, message:Error: The virtual machine is not powered on: /Users/shtanaka/.vctl/.r/vms/myNginx/myNginx.vmx module=libcrx package=sandbox ERROR failed to create container: error code:exit status 255, message:2020-09-17T15:18:02.740| ServiceImpl_Opener: PID 35878 Error: The operation was canceled
- 一度
sudo
付きで実行する
$ sudo vctl run -n myAlpine -t -d alpine INFO container myAlpine started and detached from current session $ vctl stop myAlpine WARNING container myAlpine did not stop within 10 second, force kill it... INFO container myAlpine has been stopped
sudo
付きで実行した後は、sudo
無しで実行可能
リンク
- VMware Fusionでコンテナを動かしてみる - Qiita https://qiita.com/ttani03/items/3392f28febe3e35e1f1e
- A first look at the vctl utility in VMware Fusion - CormacHogan.com https://cormachogan.com/2020/09/08/a-first-look-at-the-vctl-utility-in-vmware-fusion/
- Using vctl Command to Manage Containers and Run Kubernetes Cluster https://docs.vmware.com/en/VMware-Fusion/12/com.vmware.fusion.using.doc/GUID-78E7339F-7294-4F3E-9AD0-1E14C201FA40.html