Appleのcontainerを早速試してみた!
What is "container"?
WWDC25にて、Appleからcontainer
の発表がありました!
container is a tool that you can use to create and run Linux containers as lightweight virtual machines on your Mac. It's written in Swift, and optimized for Apple silicon.
containerはMac上でLinuxコンテナを軽量に実行することができるApple公式の仮想環境です。
イメージ的にはWindowsのWSLみたいな感じですね。
今回はインストールからコンテナ実行までを記載します。
DockerやWSLと何が違うの?みたいなお話はしないので気になる方は他の記事も参照してみてください。
以下の記事とか分かりやすかったです。
Requirements
インストール前にmacOS15以上であることを確認してください!
Installation
公式リポジトリのreleasesにインストーラーがあるので、ダウンロードしてインストールするだけ。
Getting started
起動は以下のコマンド
container system start
初回はダウンロードが必要みたいなので、以下の表示が出ました。
結構時間がかかったので、ネットワーク環境に不安のある方はご注意を。
Y
を入力して実行
Install the recommended default kernel from [https://github.com/kata-containers/kata-containers/releases/download/3.17.0/kata-static-3.17.0-arm64.tar.xz]? [Y/n]:
停止は以下のコマンド
container system stop
基本的なコマンドは以下みたいです。
container --help
OVERVIEW: A container platform for macOS
USAGE: container [--debug] <subcommand>
OPTIONS:
--debug Enable debug output [environment: CONTAINER_DEBUG]
--version Show the version.
-h, --help Show help information.
CONTAINER SUBCOMMANDS:
create Create a new container
delete, rm Delete one or more containers
exec Run a new command in a running container
inspect Display information about one or more containers
kill Kill one or more running containers
list, ls List containers
logs Fetch container stdio or boot logs
run Run a container
start Start a container
stop Stop one or more running containers
IMAGE SUBCOMMANDS:
build Build an image from a Dockerfile
images, image, i Manage images
registry, r Manage registry configurations
SYSTEM SUBCOMMANDS:
builder Manage an image builder instance
system, s Manage system components
コンテナ操作をしてみよう
コマンドオプションはコマンドごとに--help
で確認できるのでとりあえずrun
コマンドを実行してみます。
container run --help
OVERVIEW: Run a container
USAGE: container run [<options>] <image> [<arguments> ...]
ARGUMENTS:
<image> Image name
<arguments> Container init process arguments
OPTIONS:
-w, --cwd, --workdir <cwd>
Current working directory for the container
-e, --env <env> Set environment variables
--env-file <env-file> Read in a file of environment variables
--uid <uid> Set the uid for the process
--gid <gid> Set the gid for the process
-i, --interactive Keep Stdin open even if not attached
-t, --tty Open a tty with the process
-u, --user <user> Set the user for the process
-c, --cpus <cpus> Number of CPUs to allocate to the container
-m, --memory <memory> Amount of memory in bytes, kilobytes (K), megabytes (M), or gigabytes (G) for the container, with MB granularity (for example, 1024K will result in 1MB being
allocated for the container)
-d, --detach Run the container and detach from the process
--entrypoint <entrypoint>
Override the entrypoint of the image
--mount <mount> Add a mount to the container (type=<>,source=<>,target=<>,readonly)
--tmpfs <tmpfs> Add a tmpfs mount to the container at the given path
--name <name> Assign a name to the container. If excluded will be a generated UUID
--remove, --rm Remove the container after it stops
--os <os> Set OS if image can target multiple operating systems (default: linux)
-a, --arch <arch> Set arch if image can target multiple architectures (default: arm64)
-v, --volume <volume> Bind mount a volume into the container
-k, --kernel <kernel> Set a custom kernel path
--cidfile <cidfile> Write the container ID to the path provided
--no-dns Do not configure DNS in the container
--dns <dns> DNS nameserver IP address
--dns-domain <dns-domain>
Default DNS domain
--dns-search <dns-search>
DNS search domains
--dns-option <dns-option>
DNS options
-l, --label <label> Add a key=value label to the container
--disable-progress-updates
Disable progress bar updates
--scheme <scheme> Scheme to use when conntecting to the container registry. One of (http, https, auto) (default: auto)
--debug Enable debug output [environment: CONTAINER_DEBUG]
--version Show the version.
-h, --help Show help information.
適当にNode.jsを実行してみます。
ローカルに以下のファイルを準備
console.log("Hellow, container!!!");
ファイルはこんな感じで配置しています。
./
└── src
└── index.js
いざ実行
container run --rm -v "$(pwd)/src:/src" node node src/index.js
Hellow, container!!!
ちゃんとindex.jsの内容が実行されましたね!
補足
デフォルトのレジストリはdocker.io
になっているので、Docker Hubにあるイメージはそのまま使えそうでした!
container registry default inspect
docker.io
Compose相当の機能はあるの?
2025/06/11時点では存在せず、Issueが上がっていました。
Docker Desktop等のツールから完全に移行して開発するためには欲しい機能ですね。
引き続き見守ります!
Discussion