同じディストリビューションでも複数持てるようになった。でもDockerが動かない。
Docker動かず
手順とエラーメッセージを再現するためにもう一個Ubuntu18.04を作った。Dockerを起動しようとするとこんなエラーが出る。
どうやらsystemdが動かないらしい。
調べてみると、Linuxが起動するときすべてのプロセスの最初として「systemd」が起動し、すべてのプロセスの親としてふるまうようです。
(中略)
実際にWSL2上でプロセスを確認してみると、PID 1が「/init」となっていて「systemd」ではありません。
これが原因でsystemctlが動いていないようです。
エラーメッセージから考えても、PID 1がsystemdになればよい、ということです。
PID 1をsystemdにする
上記ブログでは下記をインストールしている。ただ、コマンドをコピペしてもうまくいかない。
- dotnet-runtime-3.1
- daemonize
- genie
dotnet-runtime-3.1とdaemonizeのインストール
コピペで実行するとこのようにエラーになる。
先に書かれているdotnet-runtime-3.1がエラーなのでdaemonizeはインストールされていない。
そこでまずdaemonizeをインストールする。
daemonizeはインストールできた。
次はdotnet-runtime-3.1。Microsoftのサイトを見る。
18.04 ✔️
APT を使用したインストールは、少ないコマンドで実行できます。 .NET をインストールする前に、次のコマンドを実行して、信頼されたキーの一覧に Microsoft パッケージ署名キーを追加し、パッケージ リポジトリを追加します。
ターミナルを開き、次のコマンドを実行します。
wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb()()
(中略).NET Core ランタイムを使用すると、ランタイムを含まない .NET Core を使用して作成されたアプリを実行できます。 次のコマンドを実行すると、.NET Core の最も互換性の高いランタイムである ASP.NET Core ランタイムがインストールされます。 ご利用のターミナルで、次のコマンドを実行します。
sudo apt-get update; \ sudo apt-get install -y apt-transport-https && \ sudo apt-get update && \ sudo apt-get install -y aspnetcore-runtime-3.1
やってみる。 まず前半。
うまくいった。後半も実行。
インストールできた。
genieインストール
参照元ブログでは下記のコマンド。でもmakeできない。
shigeo@EAGLEII:/mnt/c/Users/shigeo-t/genie$ make install
make: *** ターゲット 'install' を make するルールがありません. 中止.
そこで、genieをソースからmakeするのではなく直インストールする作戦を調べることに。あった。
dotnet runtimeをセットアップしたのち、genieのインストール手順に従って、/etc/apt/sources.list.d/wsl-translinux.listというファイルを作成、以下の内容を記述して、
以下のコマンドを実行してdeb [trusted=yes] https://wsl-translinux.arkane-systems.net/apt/ /systemd-genie
のインストールをします。
これでgenieのセットアップは完了で、シェル上でsudo apt updatesudo apt install systemd-genie
と実行することで、新しくシェルが起動されてsystemdが起動出来ます。
やってみる。
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下のパッケージが新たにインストールされます:
systemd-genie
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 2 個。
197 kB のアーカイブを取得する必要があります。
この操作後に追加で 660 kB のディスク容量が消費されます。
取得:1 https://wsl-translinux.arkane-systems.net/apt systemd-genie 1.28 [197 kB]
197 kB を 2秒 で取得しました (113 kB/s)
以前に未選択のパッケージ systemd-genie を選択しています。
(データベースを読み込んでいます ... 現在 49317 個のファイルとディレクトリがインストールされています。)
.../systemd-genie_1.28_amd64.deb を展開する準備をしています ...
systemd-genie (1.28) を展開しています...
systemd-genie (1.28) を設定しています ...
man-db (2.8.3-2ubuntu0.1) のトリガを処理しています ...
インストールできた。
Docker起動
早速起動してみる。
確認する。まあ動いてる。
Client:
Debug Mode: false
Server:
Containers: 7
Running: 0
Paused: 0
Stopped: 7
Images: 62
Server Version: 19.03.13
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.19.128-microsoft-standard
Operating System: Ubuntu 18.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 24.73GiB
Name: EAGLEII-wsl
ID: MYOB:MVVY:IOQF:E2YE:IYCT:CYFN:767N:AEZ6:IPVX:NY4E:A34I:UA5H
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Hello-worldを試す。
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.
(amd64)
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/
ついでにdocker run -it ubuntu bashも実行。
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
d72e567cc804: Pull complete
0f3630e5ff08: Pull complete
b6a83d81d1f4: Pull complete
Digest: sha256:bc2f7250f69267c9c6b66d7b6a81a54d3878bb85f1ebb5f951c896d13e6ba537
Status: Downloaded newer image for ubuntu:latest
root@10bb4e63d6df:/# id
uid=0(root) gid=0(root) groups=0(root)
root@10bb4e63d6df:/# exit
exit
問題無さそう。
ということで、wsl export/importで増やしたディストリビューションでDockerを というかsystemdが必要な人はこの手順で。