WIP 2026-06-09 22:46 JST
はじめに
Apple container は、コンテナを軽量 VM として動かす設計に近い。
さらに v1.0.0 では、長く使う Linux 環境を作る機能として container machine が追加された。
では、container machine はどの程度 VM に近いのか。また、containerコマンドで起動する通常のコンテナと何が違うのか。
この記事では、container machine を Linux 作業環境として見たときに、どこまで VM らしく振る舞うのかを確認する。
見たいこと
- filesystem の状態は停止後も残るのか
- PID 1 は何になるのか
- systemd や OpenRC のような init は PID 1 として動くのか
systemctlやjournalctlは使えるのか- cgroup はどう見えるのか
- hostname、network、IP アドレスはどう見えるのか
- mount はどのように見えるのか
- ホストの home mount はどの権限で見えるのか
- CPU、memory、disk はどのように見えるのか
- reboot や shutdown に近い操作はできるのか
- 通常の
container runと何が違うのか
検証方針
まず、Alpine の container machine を作る。 Alpine では OpenRC まわりを見る。
container machine create alpine:3.22 --name alpine-machine
container machine run -n alpine-machine
次に、systemd を含む Ubuntu image でも container machine を作る。 公式 how-to では、Ubuntu 24.04 に systemd、SSH、基本的な CLI ツールを入れた image を作る例が示されている。
FROM ubuntu:24.04
RUN apt-get update && \
apt-get install -y systemd dbus sudo iproute2 iputils-ping curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN systemctl set-default multi-user.target
container build -t local/ubuntu-machine:latest .
container machine create local/ubuntu-machine:latest --name ubuntu-machine
container machine run -n ubuntu-machine
その上で、Linux から見える環境を確認する。
uname -a
cat /etc/os-release
cat /proc/1/comm
readlink -f /sbin/init
ps aux
systemctl status
journalctl -b --no-pager | tail
mount
findmnt
cat /proc/self/cgroup
ip addr
df -h
free -h
同じコマンドを container run でも実行し、差分を見る。
container run --rm alpine:3.22 uname -a
container run --rm alpine:3.22 ps aux
container run --rm alpine:3.22 mount
期待していること
container machine は、Docker Desktop の中の通常のコンテナというより、軽量 VM に近い Linux 作業環境として見えるはずである。
一方で、完全な汎用 VM ではない可能性もある。 Apple container の管理下にあるため、kernel、network、mount、host integration には独自の制約があるはずである。
この差分を見ることで、container machine を開発環境や検証環境としてどこまで使えるかを整理したい。