2021-10-15 Fri: WSL2 にて Podman をお試し(podman コマンドを使用できるようになるまで)
とりあえずインストール
code:sh
❯ apt update && apt install podman
エイリアスをとりあえず張ってみる
code:sh
❯ alias docker=podman
手持ちの Dockerfile を build してみる
code:sh
❯ docker build -t hokupod/ruby_with_bundler .
ERRO0000 unable to write system event: "write unixgram @00004->/run/systemd/journal/socket: sendmsg: no such file or directory" WARN0000 Failed to detect the owner for the current cgroup: stat /sys/fs/cgroup/systemd: no such file or directory STEP 1: FROM ruby:2.7.1-alpine
✔ docker.io/library/ruby:2.7.1-alpine
Getting image source signatures
Copying blob 3396c77940f8 done
Copying blob bea36b8d88de done
Copying blob df20fa9351a1 done
Copying blob b79bab524d4c done
Copying blob 8f5dd72031b5 done
Copying config b46ea0bc59 done
Writing manifest to image destination
Storing signatures
STEP 2: ADD . /home
--> f4e62909072
STEP 3: WORKDIR /home
--> e2d04487a2e
STEP 4: RUN apk add --update build-base less && rm -rf /var/cache/apk/*
(1/19) Upgrading musl (1.1.24-r9 -> 1.1.24-r10)
(2/19) Installing binutils (2.34-r2)
(3/19) Installing libmagic (5.38-r0)
(4/19) Installing file (5.38-r0)
(5/19) Installing isl (0.18-r0)
(6/19) Installing libgomp (9.3.0-r2)
(7/19) Installing libatomic (9.3.0-r2)
(8/19) Installing libgphobos (9.3.0-r2)
(9/19) Installing mpfr4 (4.0.2-r4)
(10/19) Installing mpc1 (1.1.0-r1)
(11/19) Installing gcc (9.3.0-r2)
(12/19) Installing musl-dev (1.1.24-r10)
(13/19) Installing libc-dev (0.7.2-r3)
(14/19) Installing g++ (9.3.0-r2)
(15/19) Installing make (4.3-r0)
(16/19) Installing fortify-headers (1.1-r0)
(17/19) Installing patch (2.7.6-r7)
(18/19) Installing build-base (0.5-r2)
(19/19) Installing less (551-r0)
Executing busybox-1.31.1-r16.trigger
OK: 218 MiB in 54 packages
--> db982accd6b
STEP 5: RUN bundle install
Using bundler 2.1.4
Fetching byebug 11.1.3
Installing byebug 11.1.3 with native extensions
Fetching coderay 1.1.3
Installing coderay 1.1.3
Fetching method_source 1.0.0
Installing method_source 1.0.0
Fetching pry 0.13.1
Installing pry 0.13.1
Fetching pry-byebug 3.9.0
Installing pry-byebug 3.9.0
Bundle complete! 1 Gemfile dependency, 6 gems now installed.
Use bundle info [gemname] to see where a bundled gem is installed.
STEP 6: COMMIT hokupod/ruby_with_bundler
--> 711d86ebd6a
711d86ebd6a7baecbd397251b71cef9c5c52fd31e0045bffa6eba45a95ad5079
ERRO0062 unable to write build event: "write unixgram @00004->/run/systemd/journal/socket: sendmsg: no such file or directory" いくつか ERRO の文字がならんでいるので調べてみると、どうやら WSL2 特有のエラーらしい。
必要な設定を入れ込む
code:sh
❯ cp /usr/share/containers/containers.conf ~/.config/containers/ #雛形をコピー nvim ~/.config/containers/containers.conf
#events_logger = "journald" => events_logger = "file" に変更。
ここまでやっておいて、WSL2 環境なのに普通に apt からインストールするのはよくないのでは?と思い、入れ直し
code:sh
sudo apt remove podman
同じ URL を元に構築し直し、まずは環境変数の取得
code:sh
❯ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
❯ . /etc/os-release
❯ echo $NAME
Ubuntu
取れているっぽい。
続いてリポジトリの追加
code:sh
キーの取得と追加
code:sh
❯ sudo apt-key add - < Release.key
OK
apt-get アップデートとインストール。普段は apt を使っているが、手順に従う。
code:sh
❯ sudo apt-get update -qq
❯ sudo apt-get -qq -y install podman
(Reading database ... 109577 files and directories currently installed.)
Preparing to unpack .../crun_100%3a1.1-1_amd64.deb ...
Unpacking crun (100:1.1-1) over (100:0.18-2) ...
Preparing to unpack .../podman-plugins_100%3a1.2.0-1_amd64.deb ...
Unpacking podman-plugins (100:1.2.0-1) over (100:1.1.1-5) ...
Selecting previously unselected package podman-machine-cni.
Preparing to unpack .../podman-machine-cni_100%3a0.0.0-1_amd64.deb ...
Unpacking podman-machine-cni (100:0.0.0-1) ...
Selecting previously unselected package podman.
Preparing to unpack .../podman_100%3a3.3.1-1_amd64.deb ...
Unpacking podman (100:3.3.1-1) ...
dpkg: warning: unable to delete old directory '/etc/cni/net.d': Directory not empty
dpkg: warning: unable to delete old directory '/etc/cni': Directory not empty
Setting up crun (100:1.1-1) ...
Setting up podman-machine-cni (100:0.0.0-1) ...
Setting up podman-plugins (100:1.2.0-1) ...
Setting up podman (100:3.3.1-1) ...
Processing triggers for man-db (2.9.1-1) ...
2回目のインストールなので、ディレクトリはすでにあったけど一応メモ
code:sh
❯ sudo mkdir -p /etc/containers
conf の上書きがありそうなので、一旦退避
code:sh
❯ sudo cp /etc/containers/registries.conf{,.org}
上書きした。困ったら戻す。
code:sh
リポジトリ追加前後でバージョンが結構違う。3.4.0 が最新だと思うので、ちょっと追いついていないのかな?
code:sh
podman version 3.0.1
podman version 3.3.1
WARN が消えた。
code:sh
❯ docker images #3.0.1 エイリアスしてたので、docker になっている WARN0000 Failed to detect the owner for the current cgroup: stat /sys/fs/cgroup/systemd: no such file or directory REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/hokupod/ruby_with_bundler latest 711d86ebd6a7 24 minutes ago 307 MB
docker.io/library/ruby 2.7.1-alpine b46ea0bc5984 15 months ago 55.1 MB
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/hokupod/ruby_with_bundler latest 711d86ebd6a7 58 minutes ago 307 MB
docker.io/library/ruby 2.7.1-alpine b46ea0bc5984 15 months ago 55.1 MB
よし。次は下記を調べて、docker-compose で実行していたものを podman で動くようにする。