macOS へ Colima をインストールする
macOS でコンテナを利用する為に Colima をインストールする手順をメモしておきます。
検証環境¶
対象 | バージョン |
---|---|
macOS | Sequoia 15.4.1 |
Docker | 28.1.1, build 4eba377327 |
colima | 0.8.1 |
インストール¶
Colima は Homebrew でインストール出来ます。 コンテナエンジンも必要になりますので Docker と Docker Compose もインストールしておきます。
brew install colima docker docker-compose
以下のバージョンがインストールされました。
% docker --version
Docker version 28.1.1, build 4eba377327
% docker-compose --version
Docker Compose version 2.35.1
% colima --version
colima version 0.8.1
Colima の使い方¶
Colima 上で仮想マシンを作成する際のデフォルトスペックについて Colima - container runtimes on macOS (and Linux) with minimal setup. には以下のように記載されていました。
The default VM created by Colima has 2 CPUs, 2GiB memory and 100GiB storage.
私の場合はもっと小さい仮想マシンで問題無い為、Colima の起動オプションで低めのスペックを指定します。
colima start --cpu 2 --memory 4 --disk 10
作成された仮想マシンは colima list
で確認することが出来ます。
% colima list
PROFILE STATUS ARCH CPUS MEMORY DISK RUNTIME ADDRESS
default Running aarch64 2 4GiB 10GiB docker
後は Linux 環境などで Docker を利用するのと同様です。 下記では起動テストとして hello-world コンテナを実行しています。
% docker container run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c9c5fd25a1bd: Pull complete
Digest: sha256:c41088499908a59aae84b0a49c70e86f4731e588a737f1637e73c8c09d995654
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(arm64v8)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
コンテナの作業が終了したら Colima で作成した仮想マシンを停止しておきます。
% colima stop
INFO[0000] stopping colima
INFO[0000] stopping ... context=docker
INFO[0000] stopping ... context=vm
INFO[0003] done
Colima の仮想マシンが停止した状態だと Docker コンテナは起動しません。
% docker container run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Run 'docker run --help' for more information
参考¶
Colima のヘルプ¶
% colima help
Colima provides container runtimes on macOS with minimal setup.
Usage:
colima [command]
Available Commands:
completion Generate completion script
delete delete and teardown Colima
help Help about any command
kubernetes manage Kubernetes cluster
list list instances
nerdctl run nerdctl (requires containerd runtime)
prune prune cached downloaded assets
restart restart Colima
ssh SSH into the VM
ssh-config show SSH connection config
start start Colima
status show the status of Colima
stop stop Colima
template edit the template for default configurations
update update the container runtime
version print the version of Colima
Flags:
-h, --help help for colima
-p, --profile string profile name, for multiple instances (default "default")
-v, --verbose enable verbose log
--version version for colima
--very-verbose enable more verbose log
Use "colima [command] --help" for more information about a command.