0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntu24.04にcontainerdとnerdctlをインストールする

Last updated at Posted at 2025-05-18

この記事について

WSL2上のUbuntu24.04にnerdctlをインストールする手順。
すでに多数の記事が出回っているが、微妙に動いたり動かなかったりしたので、最短でインストールできた方法をメモする。試行錯誤の過程は全て端折って結論だけ書いている。
OSを初期化した状態から試しているので、おそらく過不足ない、はず。

環境

  • WSL2 + Ubuntu 24.04 LTS

手順

必要なパッケージのインストール

$ sudo apt update
$ sudo apt install containerd runc rootlesskit iptables

CNIプラグインを動作させるためにiptablesコマンドが必要。
Ubuntu 24.04にはデフォルトでnftablesがインストールされている。
iptablesコマンドは、実際にはiptables-nftを呼んでいるので、両方インストールしても問題ないらしい。

nerdctlのインストール

  • nerdctlのサイトに書かれている手順をそのまま実行する
$ curl -OL https://github.com/containerd/nerdctl/releases/download/v2.1.1/nerdctl-2.1.1-linux-amd64.tar.gz
$ sudo tar Cxzvvf /usr/local/bin nerdctl-2.1.1-linux-amd64.tar.gz
$ containerd-rootless-setuptool.sh install

CNIプラグインのインストール

  • /opt/cni/bin/ に置いとくと読んでくれるらしい…
$ curl -OL https://github.com/containernetworking/plugins/releases/download/v1.7.1/cni-plugins-linux-amd64-v1.7.1.tgz
$ sudo mkdir -p /opt/cni/bin/
$ sudo tar Cxzvvf /opt/cni/bin cni-plugins-linux-amd64-v1.7.1.tgz

buildkitのインストール

  • nerdctl build を実行するために必要
$ curl -OL https://github.com/moby/buildkit/releases/download/v0.21.1/buildkit-v0.21.1.linux-amd64.tar.gz
$ sudo tar Cxzvvf /usr/local/ buildkit-v0.21.1.linux-amd64.tar.gz
$ CONTAINERD_NAMESPACE=default containerd-rootless-setuptool.sh install-buildkit-containerd

動作確認

  • nerdctl のバージョン確認
$ nerdctl -v
nerdctl version 2.1.1
  • nerdctl buildの確認
$ mkdir tmp && cat <<EOF > tmp/Dockerfile
FROM alpine:3.21.3
RUN echo hello
EOF
$ cd tmp
$ nerdctl build -t mytest .
  • コンテナの実行
$ nerdctl run mytest echo "hello"
hello
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?