11
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WSL + Ubuntu で Docker を使う

Last updated at Posted at 2018-10-11

2018/10/06 に動作確認
Windows10 Home October 2018 Update

Ubuntu の入手

Microsoft Store から 『Ubuntu 16.04 LTS』 を入手

他に Microsoft Store から入手できる 『Ubuntu』 や 『Ubuntu 18.04 LTS』 では Docker を起動することができなかった。

  • 『Ubuntu』 アプリのバージョンは 2018/10/06 現在 18.04 LTS
  • 18.04 LTS でも Docker を古いバージョンにすればいけるらしい?詳細不明
$ head -n 2 /etc/os-release
# NAME="Ubuntu"
# VERSION="16.04.5 LTS (Xenial Xerus)"

Docker のインストール

管理者権限で 『Ubuntu 16.04 LTS』 を起動して以下のコマンドを実行する。

$ sudo apt update && sudo apt upgrade
$ sudo apt install docker.io
$ sudo usermod -aG docker $USER

バージョン確認

$ docker -v
# Docker version 17.03.2-ce, build f5ec1e2

Docker の実行

Docker サービスの起動

$ sudo cgroupfs-mount
$ sudo service docker start
# * Starting Docker: docker

Docker サービスの起動確認

$ sudo service docker status
# * Docker is running

管理者権限で実行していないとサービスが起動しない


コンテナ起動

$ docker run hello-world
# Unable to find image 'hello-world:latest' locally
# latest: Pulling from library/hello-world
# d1725b59e92d: Already exists
# Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
# 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/

# For more examples and ideas, visit:
# https://docs.docker.com/get-started/

成功
(docker: Got permission denied ~ が出力された時は sudo つける)


Ubuntu 18.04 LTS で Docker サービスの起動操作を行っても起動しない

$ head -n 2 /etc/os-release
# NAME="Ubuntu"
# VERSION="18.04.1 LTS (Bionic Beaver)"

$ sudo cgroupfs-mount
$ sudo service docker start
# * Starting Docker: docker

$ sudo service docker status
# * Docker is not running

$ docker run hello-world
# docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
# See 'docker run --help'.

各コンテナの起動確認

Arch Linux

$ docker run base/archlinux head -n 1 /etc/os-release
# NAME="Arch Linux"

CentOS

$ docker run centos cat /etc/redhat-release
# CentOS Linux release 7.5.1804 (Core)

Ubuntu

$ docker run ubuntu head -n 2 /etc/os-release
# NAME="Ubuntu"
# VERSION="18.04.1 LTS (Bionic Beaver)"

起動した

11
18
0

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
11
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?