LoginSignup
98
69

More than 5 years have passed since last update.

どうしても Docker on Ubuntu 18.04 on WSL したかった

Last updated at Posted at 2018-07-26

WSL上でDocker Engineが動くようになっていたっぽいという話
https://qiita.com/yanoshi/items/dcecbf117d9cbd14af87

上の記事を見て喜び勇んでやってみたら、最新のDockerでは動きませんでした.... と言うお話です。

(更新 2019/02/26) 私は結局、開発環境としてのWindowsから離れてしまったので試していませんが、Build 17713では動いたようだったので、現行ビルド (RS5, Version 1809, Build 17763.316) では普通に動くんじゃ無いかなと思います。

環境

  • Windows 10 Pro
    • Version 1803
    • Build 17134.165
  • Ubuntu 18.04
    • 16.04で docker.io を使うのであれば、バージョンが古いので多分あっさり動くと思います。
      動かないらしいです。調べてはいないですが、16.04のdocker.ioパッケージのバージョンが上がっているのかも。 (thx @ytakashina)

とりあえず試したら....

% sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9db2ca6ccae0: Extracting [==================================================>]     985B/985B
docker: failed to register layer: Error processing tar file(exit status 1): invalid argument.
See 'docker run --help'.

がーん

最初はk8sが使ってみたかったため、docker 公式パッケージ docker-ce (18.06.0~ce~3-0~ubuntu) をインストールするもダメ。
Ubuntuが用意してくれているパッケージ docker.io (17.12.1-0ubuntu1) もダメでした。

どうすれば動くんだろう

と、言う事でいろいろ調べたところ、元々Docker on WSLについて議論が行われていたRedditのスレに答えがありました。

That is this change . WSL doesn't support MS_SLAVE in mount. That error appears since docker-ce 17.09.1 but it's easy to fix if you compile latest docker yourself.

Docker 17.09.1 からマウント時に使うようになった MS_SLAVE と言うのをWSLがサポートしていないのが原因らしい。

取り急ぎ 17.09.0 で試してみる。

% curl -O https://download.docker.com/linux/debian/dists/stretch/pool/stable/amd64/docker-ce_17.09.0~ce-0~debian_amd64.deb
% sudo dpkg -i docker-ce_17.09.0\~ce-0\~debian_amd64.deb
% docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9db2ca6ccae0: Pull complete
Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
...

動いた。

と、言う事で現状どうしても Docker on Ubuntu 18.04 on WSL したいのであれば、以下の内のどれかを選ぶしか無さそうです。

  1. 17.09.0 を使う
  2. 以下コミットをRevertして自分でビルドして使う (未検証)
    https://github.com/docker/docker-ce/commit/6c6a1827cfc6c221c0477f55f20758a6e5487e5e
  3. WindowsをInsider Preview版にする (未検証。ビルド17666でMS_SLAVEがサポートされたらしい)
    RS5 の slow ring (build 17713) では hello-world が動いたらしいです。 (thx @hanotch)
  4. RS5のリリースを待つ (秋くらいですかね?)

もちろんDocker for Windowsと併用するのもアリだと思います。

WSL(Bash on Windows)でDockerを使用する
https://qiita.com/yoichiwo7/items/0b2aaa3a8c26ce8e87fe

98
69
3

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
98
69