M1 Mac に Rancher Desktop を導入して、コンテナ管理してみる (Version 1.9.1)

2023.07.11

コンテナ管理・実行環境として Rancher Desktop (Version 1.9.1) を導入してみました。

特に導入で詰まった部分はありませんでしたが、備忘録として手順や試したことを記録します。

前提

Rancher Desktop について

Rancher Desktop – Container Management and Kubernetes on the Desktop

Rancher Desktop はデスクトップ上で コンテナ管理とKubernetesを提供します。 オープンソースのアプリケーションで、 Mac/Windows/Linux に対応しています。

ローカル端末について

MacBook Pro(Apple M1 Max) 上に Rancher Desktop を入れて確かめます。

セットアップ

公式ドキュメントの Installation を参考に進めます。

インストール

リリースページ(GitHub) から最新版の Rancher Desktop のアセット Rancher.Desktop-X.Y.Z.dmg をダウンロードします。

私は執筆時点のARM最新版 Rancher.Desktop-1.9.1.aarch64.dmg をダウンロードしました。

ダウンロードしたDMGファイルを選択します。 以下のようなウィンドウが出るので、Applicationに入れましょう。

img

初回起動

Rancher Desktop を開いてみます。以下のようなアイコンです。

img

セキュリティ通知が出る場合は、そのまま [開く] を選択します。

img

[Welcome to Rancher Desktop] の画面が開きます。 ここで初期設定の選択を行います。

img

私は以下のような設定としました。

  • Enable Kubernetes チェックは外す
  • Container Engine は containerd (nerdctlコマンド) を選択
  • パス設定は Automatic を選択

以下のような画面が出たら、初期セットアップはおそらく完了です。

img

ターミナルからも nerdctl コマンドが実行できていることを確認できました。

$ which nerdctl
/Users/kawahara.masahiro/.rd/bin/nerdctl

$ nerdctl --help | head
nerdctl is a command line interface for containerd

Config file ($NERDCTL_TOML): /etc/nerdctl/nerdctl.toml

Usage: nerdctl [flags]

Management commands:
  apparmor   Manage AppArmor profiles
  builder    Manage builds
  container  Manage containers

なお containerd もしくは dockerd の変更は以下設定から変更可能です。

img

Hello World Example をやってみる

Hellow World ExampleExample#1 - Build Image & Run Container を試してみます。

以降は nerdctl での出力結果を記載します。

下準備

フォルダーを作成します。

$ mkdir hello-world
$ cd hello-world

Dockerfile を作成して、以下内容を記載します。

FROM alpine  
CMD ["echo", "Hello World!!"]

イメージのビルド

nerdctl build コマンドでコンテナをビルドします。

$ nerdctl build --tag helloworld:v1.0 .
nerdctl build --tag helloworld:v1.0 .
[+] Building 11.1s (4/5)
 => [internal] load build definition from Dockerfile                       0.0s
[+] Building 11.2s (5/5) FINISHED
 => [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 81B                                        0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => [internal] load metadata for docker.io/library/alpine:latest          10.5s
 => [1/1] FROM docker.io/library/alpine@sha256:82d1e9d7ed48a7523bdebc18cf  0.6s
 => => resolve docker.io/library/alpine@sha256:82d1e9d7ed48a7523bdebc18cf  0.0s
 => => sha256:8c6d1654570f041603f4cef49c320c8f6f3e4013249 3.33MB / 3.33MB  0.5s
 => exporting to docker image format                                       0.6s
 => => exporting layers                                                    0.0s
 => => exporting manifest sha256:b1f125adbd7146d133732f0c5b6a8ee9639c887e  0.0s
 => => exporting config sha256:86368eb2a920b51f6984bcd4624bf884c8dd8d891d  0.0sa => => sending tarball                                                     0.1s
Loaded image: docker.io/library/helloworld:v1.0

イメージのリスト

nerdctl images コマンドでイメージ一覧をリストできます。

$ nerdctl images
REPOSITORY    TAG     IMAGE ID        CREATED           PLATFORM       SIZE       BLOB SIZE
helloworld    v1.0    b1f125adbd71    56 seconds ago    linux/arm64    8.0 MiB    3.2 MiB

コンテナ実行

nerdctl run コマンドでコンテナを実行します。

$ nerdctl run --rm helloworld:v1.0
Hello World!!

イメージの削除

nerdctl rmi コマンドで作成したイメージを削除します。

$ nerdctl rmi helloworld:v1.0 
nerdctl rmi helloworld:v1.0
Untagged: docker.io/library/helloworld:v1.0@sha256:b1f125adbd7146d133732f0c5b6a8ee9639c887e9d8e5fa390dbdb79950152f0
Deleted: sha256:61f2871f545a9b23a9340f96b331fb660b43008a9e84a03ad8564271bce5743b

おわりに

Rancher Desktop を使ったコンテナ管理・実行環境を導入してみました。 特に導入で詰まった部分も無くスムーズにセットアップできました。

参考になれば幸いです。

参考