WSL環境でDockerが動作しなくなった

うっかりapt update && sudo apt -y upgradeしてしまったらWSL環境でDockerが動作しなくなった

アップデート後の動作しなくなったバージョン

$ docker version
Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.1
 Git commit:        e68fc7a
 Built:             Fri Jan 25 14:33:51 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.1
  Git commit:       e68fc7a
  Built:            Thu Jan 24 10:49:48 2019
  OS/Arch:          linux/amd64
  Experimental:     false

hello-worldしてみた

$ docker run hello-world
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:301: running exec setns process for init caused \"exit status 23\"": unknown.
ERRO[0001] error waiting for container: context canceled

バージョンを戻してみる

戻せそうなバージョンを確認する

apt show [インストールパッケージ名] -aでパッケージのインストールできるバージョンの一覧を取得できる

$ sudo apt show docker.io -a
Package: docker.io
Version: 18.06.1-0ubuntu1.2~18.04.1
Built-Using: glibc (= 2.27-3ubuntu1)
Priority: optional
Section: universe/admin
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Paul Tagliamonte <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 197 MB
Provides: docker-containerd, docker-runc
Depends: adduser, iptables, debconf (>= 0.5) | debconf-2.0, libc6 (>= 2.14), libdevmapper1.02.1 (>= 2:1.02.97), libltdl7 (>= 2.4.6), libseccomp2 (>= 2.3.0)
Recommends: ca-certificates, cgroupfs-mount | cgroup-lite, git, pigz, ubuntu-fan, xz-utils, apparmor
Suggests: aufs-tools, btrfs-progs, debootstrap, docker-doc, rinse, zfs-fuse | zfsutils
Conflicts: docker-containerd, docker-runc
Breaks: docker (<< 1.5~)
Replaces: docker (<< 1.5~), docker-containerd, docker-runc
Homepage: https://www.docker.com/community-edition
Download-Size: 40.2 MB
APT-Manual-Installed: yes
APT-Sources: http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
Description: Linux container runtime
 Docker complements kernel namespacing with a high-level API which operates at
 the process level. It runs unix processes with strong guarantees of isolation
 and repeatability across servers.
 .
 Docker is a great building block for automating distributed systems:
 large-scale web deployments, database clusters, continuous deployment systems,
 private PaaS, service-oriented architectures, etc.
 .
 This package contains the daemon and client. Using docker.io on non-amd64 hosts
 is not supported at this time. Please be careful when using it on anything
 besides amd64.
 .
 Also, note that kernel version 3.8 or above is required for proper operation of
 the daemon process, and that any lower versions may have subtle and/or glaring
 issues.

Package: docker.io
Version: 17.12.1-0ubuntu1
Built-Using: glibc (= 2.27-3ubuntu1)
Priority: optional
Section: universe/admin
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Paul Tagliamonte <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 137 MB
Provides: docker-containerd, docker-runc
Depends: adduser, iptables, debconf (>= 0.5) | debconf-2.0, libc6 (>= 2.14), libdevmapper1.02.1 (>= 2:1.02.97), libltdl7 (>= 2.4.6), libseccomp2 (>= 2.3.0)
Recommends: ca-certificates, cgroupfs-mount | cgroup-lite, git, ubuntu-fan, xz-utils, apparmor
Suggests: aufs-tools, btrfs-tools, debootstrap, docker-doc, rinse, zfs-fuse | zfsutils
Conflicts: docker-containerd, docker-runc
Breaks: docker (<< 1.5~)
Replaces: docker (<< 1.5~), docker-containerd, docker-runc
Homepage: https://www.docker.com/community-edition
Download-Size: 30.1 MB
APT-Sources: http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
Description: Linux container runtime
 Docker complements kernel namespacing with a high-level API which operates at
 the process level. It runs unix processes with strong guarantees of isolation
 and repeatability across servers.
 .
 Docker is a great building block for automating distributed systems:
 large-scale web deployments, database clusters, continuous deployment systems,
 private PaaS, service-oriented architectures, etc.
 .
 This package contains the daemon and client. Using docker.io on non-amd64 hosts
 is not supported at this time. Please be careful when using it on anything
 besides amd64.
 .
 Also, note that kernel version 3.8 or above is required for proper operation of
 the daemon process, and that any lower versions may have subtle and/or glaring
 issues.

「Version: 17.12.1-0ubuntu1」に戻してみよう

一旦削除する

$ sudo apt remove docker.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bridge-utils cgroupfs-mount libfreetype6 libltdl7 pigz ubuntu-fan
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  docker.io
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 197 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 28873 files and directories currently installed.)
Removing docker.io (18.06.1-0ubuntu1.2~18.04.1) ...
'/usr/share/docker.io/contrib/nuke-graph-directory.sh' -> '/var/lib/docker/nuke-graph-directory.sh'
invoke-rc.d: could not determine current runlevel
 * Stopping Docker: docker                                                                   [ OK ]
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

バージョンを指定して再インストールする

$ sudo apt -y install docker.io=17.12.1-0ubuntu1
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfreetype6 pigz
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  aufs-tools debootstrap docker-doc rinse zfs-fuse | zfsutils
The following NEW packages will be installed:
  docker.io
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 30.1 MB of archives.
After this operation, 137 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/universe amd64 docker.io amd64 17.12.1-0ubuntu1 [30.1
MB]
Fetched 30.1 MB in 1min 56s (259 kB/s)
Preconfiguring packages ...
Selecting previously unselected package docker.io.
(Reading database ... 28675 files and directories currently installed.)
Preparing to unpack .../docker.io_17.12.1-0ubuntu1_amd64.deb ...
Unpacking docker.io (17.12.1-0ubuntu1) ...
Setting up docker.io (17.12.1-0ubuntu1) ...
invoke-rc.d: could not determine current runlevel
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu10.13) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

指定したバージョンがインストールできた

$  docker version
Client:
 Version:       17.12.1-ce
 API version:   1.35
 Go version:    go1.10.1
 Git commit:    7390fc6
 Built: Wed Apr 18 01:23:11 2018
 OS/Arch:       linux/amd64

Server:
 Engine:
  Version:      17.12.1-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.10.1
  Git commit:   7390fc6
  Built:        Wed Feb 28 17:46:05 2018
  OS/Arch:      linux/amd64
  Experimental: false

hello-worldも動いた

$ docker run 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/

まとめ

旧バージョンに戻すという根本的な解決ではない形になったが、WSLでDockerが動作しないのはとても困るので当面これで逃げることにする