LoginSignup
137

More than 3 years have passed since last update.

[2019年1月版]WSL + Ubuntu で Docker が動くっ!動くぞコイツッ!

Last updated at Posted at 2019-01-02

WSL + UbuntuでDockerを動作させてみたい

2019.01.01時点で、ゼロから環境構築をした場合には成功していません!
2019.01.02時点で成功しました! Ubuntu16.04 + Docker CE 17.03.3 で動きました!

Windows10 Pro バージョン 1803 でWSL+Dockerの環境構築を試行中です。
以下、各バージョンについてインストールと動作確認を行ったメモ。

Ubuntu 18.04 LTS + Docker 18.06

  1. Microsoft Store からUbuntu 18.04をインストール
  2. Ubuntu 18.04を実行(管理者ではない)
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ sudo apt install -y docker.io
$ sudo usermod -aG docker $USER

5.いったんターミナルを閉じる
6.再度、Ubuntu 18.04を右クリックで管理者として実行
7.dockerサービスを起動

$ sudo cgroupfs-mount
$ sudo service docker start

8.docker versionでサービスの起動を確認

Client:
Version:           18.06.1-ce
API version:       1.38
Go version:        go1.10.4
Git commit:        e68fc7a
Built:             Fri Oct 19 19:43:14 2018
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.4
Git commit:       e68fc7a
Built:            Thu Sep 27 02:39:50 2018
OS/Arch:          linux/amd64
Experimental:     false

9.ここで以下のようなsockにアクセスできないエラーが発生した場合は再度、ターミナルを閉じて再度開き、7.の手順を行えばOK。何度やってもダメな場合はタスクマネージャーからwsl.exeが動いていないか確認する。要はwsl.exeの再起動が必要っぽい。また、cgroupfs-mountはターミナル開いたら都度、行う必要あり。

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

10.docker run hello-worldでdockerを動かしてみる。

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

11.Ubuntuをそっとアンインストール

Ubuntu 16.04 LTS + Docker 18.06

  1. Microsoft Store からUbuntu 16.04をインストール
  2. Ubuntu 16.04を実行(管理者ではない)
  3. Linuxユーザーを作成
  4. 以下を実行
sudo apt update && sudo apt upgrade -y
sudo apt install -y docker.io
sudo usermod -aG docker $USER
  1. いったんターミナルを閉じる
  2. 再度、Ubuntu 16.04を右クリックで管理者として実行
  3. dockerサービスを起動
sudo cgroupfs-mount
sudo service docker start
  1. docker versionでサービスの起動を確認
$ docker version
Client:
Version:           18.06.1-ce
API version:       1.38
Go version:        go1.10.4
Git commit:        e68fc7a
Built:             Thu Nov 15 21:12:47 2018
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.4
Git commit:       e68fc7a
Built:            Sun Nov 11 21:53:22 2018
OS/Arch:          linux/amd64
Experimental:     false

9.docker run hello-worldでdockerを動かしてみる。

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

10.Ubuntuをそっとアンインストール

Ubuntuのリポジトリに登録されている安定版では動かない模様なので、以後はdockerのリポジトリを追加してバージョンを指定してインストを行う。

Ubuntu 18.04 LTS + Docker 18.09

  1. Microsoft Store からUbuntu 18.04をインストール
  2. Ubuntu 18.04を実行(管理者ではない)
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt install -y docker-ce
$ sudo usermod -aG docker $USER
  1. 以下のサービス用のスクリプトを作成(docker.ioで作成されるスクリプトをdockerd-ceに書き換えただけ)
$cat /etc/init.d/docker
#!/bin/sh
set -e

### BEGIN INIT INFO
# Provides:           docker
# Required-Start:     $syslog $remote_fs
# Required-Stop:      $syslog $remote_fs
# Should-Start:       cgroupfs-mount cgroup-lite
# Should-Stop:        cgroupfs-mount cgroup-lite
# Default-Start:      2 3 4 5
# Default-Stop:       0 1 6
# Short-Description:  Create lightweight, portable, self-sufficient containers.
# Description:
#  Docker is an open-source project to easily create lightweight, portable,
#  self-sufficient containers from any application. The same container that a
#  developer builds and tests on a laptop can run at scale, in production, on
#  VMs, bare metal, OpenStack clusters, public clouds and more.
### END INIT INFO

export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

BASE=docker

# modify these in /etc/default/$BASE (/etc/default/docker)
DOCKERD=/usr/bin/dockerd-ce
# This is the pid file managed by docker itself
DOCKER_PIDFILE=/var/run/$BASE.pid
# This is the pid file created/managed by start-stop-daemon
DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
DOCKER_LOGFILE=/var/log/$BASE.log
DOCKER_OPTS=
DOCKER_DESC="Docker"

# Get lsb functions
. /lib/lsb/init-functions

if [ -f /etc/default/$BASE ]; then
       . /etc/default/$BASE
fi

# Check docker is present
if [ ! -x $DOCKERD ]; then
       log_failure_msg "$DOCKERD not present or not executable"
       exit 1
fi

check_init() {
       # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly)
       if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
               log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1"
               exit 1
       fi
}

fail_unless_root() {
       if [ "$(id -u)" != '0' ]; then
               log_failure_msg "$DOCKER_DESC must be run as root"
               exit 1
       fi
}

devicemapper_umount() {
       # Cleanup any stale mounts left from previous shutdown
       # see https://bugs.launchpad.net/ubuntu/+source/docker.io/+bug/1404300
       grep "mapper/docker" /proc/mounts | awk '{ print $2 }' | \
               xargs -r umount || true
}

case "$1" in
       start)
               check_init

               fail_unless_root

               devicemapper_umount

               touch "$DOCKER_LOGFILE"
               chgrp docker "$DOCKER_LOGFILE"

               ulimit -n 1048576

               # Having non-zero limits causes performance problems due to accounting overhead
               # in the kernel. We recommend using cgroups to do container-local accounting.
               if [ "$BASH" ]; then
                       ulimit -u unlimited
               else
                       ulimit -p unlimited
               fi

               log_begin_msg "Starting $DOCKER_DESC: $BASE"
               start-stop-daemon --start --background \
                       --no-close \
                       --exec "$DOCKERD" \
                       --pidfile "$DOCKER_SSD_PIDFILE" \
                       --make-pidfile \
                       -- \
                               -p "$DOCKER_PIDFILE" \
                               $DOCKER_OPTS \
                                       >> "$DOCKER_LOGFILE" 2>&1
               log_end_msg $?
               ;;

       stop)
               check_init
               fail_unless_root
               if [ -f "$DOCKER_SSD_PIDFILE" ]; then
                       log_begin_msg "Stopping $DOCKER_DESC: $BASE"
                       start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE" --retry 10
                       log_end_msg $?
               else
                       log_warning_msg "Docker already stopped - file $DOCKER_SSD_PIDFILE not found."
               fi
;;

       restart)
               check_init
               fail_unless_root
               docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
               [ -n "$docker_pid" ] \
                       && ps -p $docker_pid > /dev/null 2>&1 \
                       && $0 stop
               $0 start
               ;;

       force-reload)
               check_init
               fail_unless_root
               $0 restart
               ;;

       status)
               check_init
               status_of_proc -p "$DOCKER_SSD_PIDFILE" "$DOCKERD" "$DOCKER_DESC"
               ;;

       *)
               echo "Usage: service docker {start|stop|restart|status}"
               exit 1
               ;;
esac

5.実行権限を追加

$ sudo chmod 700 /etc/init.d/docker

6.いったんターミナルを閉じる
7.再度、Ubuntu 18.04を右クリックで管理者として実行
8.dockerサービスを起動

$ sudo cgroupfs-mount
$ sudo service docker start

9.docker versionでサービスの起動を確認

Client:
Version:           18.09.0
API version:       1.39
Go version:        go1.10.4
Git commit:        4d60db4
Built:             Wed Nov  7 00:49:01 2018
OS/Arch:           linux/amd64
Experimental:      false

Server: Docker Engine - Community
Engine:
 Version:          18.09.0
 API version:      1.39 (minimum version 1.12)
 Go version:       go1.10.4
 Git commit:       4d60db4
 Built:            Wed Nov  7 00:16:44 2018
 OS/Arch:          linux/amd64
 Experimental:     false

10.docker run hello-worldでdockerを動かしてみる。

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

11.Ubuntu18.04をそっとアンインストール

Ubuntu 16.04 LTS + Docker 18.09

  1. Microsoft Store からUbuntu 16.04をインストール
  2. Ubuntu 16.04を実行(管理者ではない)
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt update
$ sudo apt install -y docker-ce
$ sudo usermod -aG docker $USER
  1. いったんターミナルを閉じる
  2. 再度、Ubuntu 16.04を右クリックで管理者として実行
  3. dockerサービスを起動
$ sudo cgroupfs-mount

8.以下のサービス用のスクリプトを作成(docker.ioで作成されるスクリプトをdockerd-ceに書き換えただけ)

$cat /etc/init.d/docker
#!/bin/sh
set -e

### BEGIN INIT INFO
# Provides:           docker
# Required-Start:     $syslog $remote_fs
# Required-Stop:      $syslog $remote_fs
# Should-Start:       cgroupfs-mount cgroup-lite
# Should-Stop:        cgroupfs-mount cgroup-lite
# Default-Start:      2 3 4 5
# Default-Stop:       0 1 6
# Short-Description:  Create lightweight, portable, self-sufficient containers.
# Description:
#  Docker is an open-source project to easily create lightweight, portable,
#  self-sufficient containers from any application. The same container that a
#  developer builds and tests on a laptop can run at scale, in production, on
#  VMs, bare metal, OpenStack clusters, public clouds and more.
### END INIT INFO

export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

BASE=docker

# modify these in /etc/default/$BASE (/etc/default/docker)
DOCKERD=/usr/bin/dockerd-ce
# This is the pid file managed by docker itself
DOCKER_PIDFILE=/var/run/$BASE.pid
# This is the pid file created/managed by start-stop-daemon
DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
DOCKER_LOGFILE=/var/log/$BASE.log
DOCKER_OPTS=
DOCKER_DESC="Docker"

# Get lsb functions
. /lib/lsb/init-functions

if [ -f /etc/default/$BASE ]; then
       . /etc/default/$BASE
fi

# Check docker is present
if [ ! -x $DOCKERD ]; then
       log_failure_msg "$DOCKERD not present or not executable"
       exit 1
fi

check_init() {
       # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly)
       if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
               log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1"
               exit 1
       fi
}

fail_unless_root() {
       if [ "$(id -u)" != '0' ]; then
               log_failure_msg "$DOCKER_DESC must be run as root"
               exit 1
       fi
}

devicemapper_umount() {
       # Cleanup any stale mounts left from previous shutdown
       # see https://bugs.launchpad.net/ubuntu/+source/docker.io/+bug/1404300
       grep "mapper/docker" /proc/mounts | awk '{ print $2 }' | \
               xargs -r umount || true
}

case "$1" in
       start)
               check_init

               fail_unless_root

               devicemapper_umount

               touch "$DOCKER_LOGFILE"
               chgrp docker "$DOCKER_LOGFILE"

               ulimit -n 1048576

               # Having non-zero limits causes performance problems due to accounting overhead
               # in the kernel. We recommend using cgroups to do container-local accounting.
               if [ "$BASH" ]; then
                       ulimit -u unlimited
               else
                       ulimit -p unlimited
               fi

               log_begin_msg "Starting $DOCKER_DESC: $BASE"
               start-stop-daemon --start --background \
                       --no-close \
                       --exec "$DOCKERD" \
                       --pidfile "$DOCKER_SSD_PIDFILE" \
                       --make-pidfile \
                       -- \
                               -p "$DOCKER_PIDFILE" \
                               $DOCKER_OPTS \
                                       >> "$DOCKER_LOGFILE" 2>&1
               log_end_msg $?
               ;;

       stop)
               check_init
               fail_unless_root
               if [ -f "$DOCKER_SSD_PIDFILE" ]; then
                       log_begin_msg "Stopping $DOCKER_DESC: $BASE"
                       start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE" --retry 10
                       log_end_msg $?
               else
                       log_warning_msg "Docker already stopped - file $DOCKER_SSD_PIDFILE not found."
               fi
;;

       restart)
               check_init
               fail_unless_root
               docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
               [ -n "$docker_pid" ] \
                       && ps -p $docker_pid > /dev/null 2>&1 \
                       && $0 stop
               $0 start
               ;;

       force-reload)
               check_init
               fail_unless_root
               $0 restart
               ;;

       status)
               check_init
               status_of_proc -p "$DOCKER_SSD_PIDFILE" "$DOCKERD" "$DOCKER_DESC"
               ;;

       *)
               echo "Usage: service docker {start|stop|restart|status}"
               exit 1
               ;;
esac

9.以下でサービスを実行

$ sudo chmod 700 /etc/init.d/docker
$ sudo service docker start

10.docker versionでサービスの起動を確認

$ docker version
Client:
Version:           18.09.0
API version:       1.39
Go version:        go1.10.4
Git commit:        4d60db4
Built:             Wed Nov  7 00:48:57 2018
OS/Arch:           linux/amd64
Experimental:      false

Server: Docker Engine - Community
Engine:
 Version:          18.09.0
 API version:      1.39 (minimum version 1.12)
 Go version:       go1.10.4
 Git commit:       4d60db4
 Built:            Wed Nov  7 00:16:44 2018
 OS/Arch:          linux/amd64
 Experimental:     false

11.docker run hello-worldでdockerを動かしてみる。

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

12.Ubuntu16.04をそっとアンインストール

Ubuntu 18.04 LTS + Docker 18.03

  1. Microsoft Store からUbuntu 18.04をインストール
  2. Ubuntu 18.04を実行(管理者ではない)
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt install -y docker-ce=18.03.1~ce~3-0~ubuntu
$ sudo usermod -aG docker $USER

5.いったんターミナルを閉じる
6.再度、Ubuntu 18.04を右クリックで管理者として実行
7.dockerサービスを起動

$ sudo cgroupfs-mount
$ sudo service docker start

8.docker versionでサービスの起動を確認

$ docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Wed Jun 20 21:43:51 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm

Server:
Engine:
 Version: 18.03.1-ce
 API version: 1.37 (minimum version 1.12)
 Go version: go1.9.5
 Git commit: 9ee9f40
 Built: Wed Jun 20 21:42:00 2018

9.docker run hello-worldでdockerを動かしてみる。

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

10.Ubuntuをそっとアンインストール

Ubuntu 16.04 LTS + Docker 18.03

  1. Microsoft Store からUbuntu 16.04をインストール
  2. Ubuntu 16.04を右クリックして管理者として実行
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt update
$ sudo apt install -y docker-ce=18.03.1~ce-0~ubuntu
$ sudo usermod -aG docker $USER

5.いったんターミナルを閉じる
6.再度、Ubuntu 16.04を右クリックで管理者として実行
7.dockerサービスを起動

sudo cgroupfs-mount
sudo service docker start

8.docker versionでサービスの起動を確認

$ docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:17:20 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm

Server:
Engine:
 Version: 18.03.1-ce
 API version: 1.37 (minimum version 1.12)
 Go version: go1.9.5
 Git commit: 9ee9f40
 Built: Thu Apr 26 07:15:30 2018

9.docker run hello-worldでdockerを動かしてみる。

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

10.Ubuntuをそっとアンインストール

Ubuntu 18.04 LTS + Docker 17.12

  1. Microsoft Store からUbuntu 18.04をインストール
  2. Ubuntu 18.04を実行(管理者ではない)
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt install -y docker.io=17.12.1-0ubuntu1
$ sudo usermod -aG docker $USER

5.いったんターミナルを閉じる
6.再度、Ubuntu 18.04を右クリックで管理者として実行
7.dockerサービスを起動

$ sudo cgroupfs-mount
$ sudo service docker start

8.docker versionでサービスの起動を確認

$ 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

9.docker run hello-worldでdockerを動かしてみる。

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

10.Ubuntuをそっとアンインストール

Ubuntu 16.04 LTS + Docker 17.12

  1. Microsoft Store からUbuntu 16.04をインストール
  2. Ubuntu 16.04を右クリックして管理者として実行
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt update
$ sudo apt install -y docker-ce=17.12.1~ce-0~ubuntu
$ sudo usermod -aG docker $USER

5.いったんターミナルを閉じる
6.再度、Ubuntu 16.04を右クリックで管理者として実行
7.dockerサービスを起動

sudo cgroupfs-mount
sudo service docker start

8.docker versionでサービスの起動を確認

$ docker version
Client:
Version:       17.12.1-ce
API version:   1.35
Go version:    go1.9.4
Git commit:    7390fc6
Built: Tue Feb 27 22:17:40 2018
OS/Arch:       linux/amd64

Server:
Engine:
 Version:      17.12.1-ce
 API version:  1.35 (minimum version 1.12)
 Go version:   go1.9.4
 Git commit:   7390fc6
 Built:        Tue Feb 27 22:16:13 2018
 OS/Arch:      linux/amd64
 Experimental: false

9.docker run hello-worldでdockerを動かしてみる。

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

10.Ubuntuをそっとアンインストール

Ubuntu 16.04 LTS + Docker 17.09

  1. Microsoft Store からUbuntu 16.04をインストール
  2. Ubuntu 16.04を右クリックして管理者として実行
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt update
$ sudo apt install -y docker-ce=17.09.1~ce-0~ubuntu
$ sudo usermod -aG docker $USER

5.いったんターミナルを閉じる
6.再度、Ubuntu 16.04を右クリックで管理者として実行
7.dockerサービスを起動

sudo cgroupfs-mount
sudo service docker start

8.docker versionでサービスの起動を確認

$ docker version
Client:
Version:      17.09.1-ce
API version:  1.32
Go version:   go1.8.3
Git commit:   19e2cf6
Built:        Thu Dec  7 22:24:23 2017
OS/Arch:      linux/amd64

Server:
Version:      17.09.1-ce
API version:  1.32 (minimum version 1.12)
Go version:   go1.8.3
Git commit:   19e2cf6
Built:        Thu Dec  7 22:23:00 2017
OS/Arch:      linux/amd64
Experimental: false

9.docker run hello-worldでdockerを動かしてみる。

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

10.Ubuntuをそっとアンインストール

Ubuntu 18.04 LTS + Docker 18.06.0

  1. Microsoft Store からUbuntu 18.04をインストール
  2. Ubuntu 18.04を実行(管理者ではない)
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt install -y docker-ce=18.06.0~ce~3-0~ubuntu
$ sudo usermod -aG docker $USER

5.いったんターミナルを閉じる
6.再度、Ubuntu 18.04を右クリックで管理者として実行
7.dockerサービスを起動

$ sudo cgroupfs-mount
$ sudo service docker start

8.docker versionでサービスの起動を確認

$ docker version
Client:
Version:           18.06.0-ce
API version:       1.38
Go version:        go1.10.3
Git commit:        0ffa825
Built:             Wed Jul 18 19:09:54 2018
OS/Arch:           linux/amd64
Experimental:      false

Server:
Engine:
 Version:          18.06.0-ce
 API version:      1.38 (minimum version 1.12)
 Go version:       go1.10.3
 Git commit:       0ffa825
 Built:            Wed Jul 18 19:07:56 2018
 OS/Arch:          linux/amd64
 Experimental:     false

9.docker run hello-worldでdockerを動かしてみる。

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

10.Ubuntuをそっとアンインストール

Ubuntu 16.04 LTS + Docker 18.06.0

  1. Microsoft Store からUbuntu 16.04をインストール
  2. Ubuntu 16.04を右クリックして管理者として実行
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt update
$ sudo apt install -y docker-ce=18.06.0~ce~3-0~ubuntu
$ sudo usermod -aG docker $USER

5.いったんターミナルを閉じる
6.再度、Ubuntu 16.04を右クリックで管理者として実行
7.dockerサービスを起動

sudo cgroupfs-mount
sudo service docker start

8.docker versionでサービスの起動を確認

$ docker version
Client:
Version:           18.06.0-ce
API version:       1.38
Go version:        go1.10.3
Git commit:        0ffa825
Built:             Wed Jul 18 19:11:02 2018
OS/Arch:           linux/amd64
Experimental:      false

Server:
Engine:
 Version:          18.06.0-ce
 API version:      1.38 (minimum version 1.12)
 Go version:       go1.10.3
 Git commit:       0ffa825
 Built:            Wed Jul 18 19:09:05 2018
 OS/Arch:          linux/amd64
 Experimental:     false

9.docker run hello-worldでdockerを動かしてみる。

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

10.Ubuntuをそっとアンインストール

Ubuntu 18.04 LTS + Docker 18.05

  1. Microsoft Store からUbuntu 18.04をインストール
  2. Ubuntu 18.04を実行(管理者ではない)
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt install -y docker-ce=18.05.0~ce~3-0~ubuntu
$ sudo usermod -aG docker $USER

5.いったんターミナルを閉じる
6.再度、Ubuntu 18.04を右クリックで管理者として実行
7.dockerサービスを起動

$ sudo cgroupfs-mount
$ sudo service docker start

8.docker versionでサービスの起動を確認

$ docker version
Client:
Version:      18.05.0-ce
API version:  1.37
Go version:   go1.9.5
Git commit:   f150324
Built:        Wed May  9 22:16:13 2018
OS/Arch:      linux/amd64
Experimental: false
Orchestrator: swarm

Server:
Engine:
 Version:      18.05.0-ce
 API version:  1.37 (minimum version 1.12)
 Go version:   go1.9.5
 Git commit:   f150324
 Built:        Wed May  9 22:14:23 2018
 OS/Arch:      linux/amd64
 Experimental: false

9.docker run hello-worldでdockerを動かしてみる。

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

10.Ubuntuをそっとアンインストール

Ubuntu 16.04 LTS + Docker 17.03.3

  1. Microsoft Store からUbuntu 16.04をインストール
  2. Ubuntu 16.04を右クリックして管理者として実行
  3. Linuxユーザーを作成
  4. 以下を実行
$ sudo apt update && sudo apt upgrade -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"
$ sudo apt update
$ sudo apt install -y docker-ce=17.03.3~ce-0~ubuntu-xenial
$ sudo usermod -aG docker $USER

5.いったんターミナルを閉じる
6.再度、Ubuntu 16.04を右クリックで管理者として実行
7.dockerサービスを起動

sudo cgroupfs-mount
sudo service docker start

8.docker versionでサービスの起動を確認

$ docker version
Client:
Version:      17.03.3-ce
API version:  1.27
Go version:   go1.7.5
Git commit:   e19b718
Built:        Thu Aug 30 01:04:51 2018
OS/Arch:      linux/amd64

Server:
Version:      17.03.3-ce
API version:  1.27 (minimum version 1.12)
Go version:   go1.7.5
Git commit:   e19b718
Built:        Thu Aug 30 01:04:51 2018
OS/Arch:      linux/amd64
Experimental: false

9.docker run hello-worldでdockerを動かしてみる。

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest

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/

10.動いたーーーーーーー!

cgroupfs-mountについて

サービス起動のスクリプトを確認していたらcgroupfs-mountを呼んでました。
都度、実行する必要はなかったです。

まとめ

以上、笑ってはいけない環境構築でした。

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
137