0
2

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.

Ubuntu 16.04 LTS に Docker CE をインストールする

0
Last updated at Posted at 2019-04-14
動作環境
  • Ubuntu 16.04.6 LTS / x86_64

Docker のエディションについて

公式ドキュメント:Overview of Docker editionsによると、Docker には以下の2つのエディションが存在します。

  • Community Edition (CE):無償。個人、小規模なチーム向け。
  • Enterprise Edition (EE):有償。商用、大規模チーム向け。

今回は個人でのお試し環境ということで、タイトル通り CE をインストールしました。

インストール

何かに躓いたら追記しようと思っていましたが、特に問題が無かったので、
ほぼ公式ドキュメント:Get Docker CE for Ubuntuの抜粋&日本語化になってしまいました。

事前準備

古いバージョンのアンインストール

古いパッケージ(docker, docker.io , or docker-engine)がインストールされていたら削除します。

$ sudo apt-get remove docker docker-engine docker.io containerd runc

インストール

以下の3つの方法でインストールが可能です。

  1. 公式リポジトリを使う (apt コマンドを使う)
  2. DEB パッケージを使う
  3. インストール用スクリプトを使う

今回はリポジトリを使う方法でインストールしてみました。

リポジトリを使ったインストール

リポジトリのセットアップ

# インデックスの更新
$ sudo apt-get update
# 前提パッケージのインストール
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
# Dockerの公式 GPG key の登録
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
# リポジトリの追加
## x86_64 / amd64 の場合
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
## armhf の場合
$ sudo add-apt-repository "deb [arch=armhf] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
## arm64 の場合
$ sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

”stable”の部分は"test"や"nightly"にも変更できます。

  • Stable: 最新の標準リリースバージョン
  • Test: テスト用のプレリリースバージョン
  • Nightly: 開発中の最新ビルド

新しい機能を使いたい等の理由が無ければ、Stable 版が問題も出にくいので良いと思います。

Docker CE のインストール

# インデックスの更新
$ sudo apt-get update
# Docker CE のインストール
## 最新バージョンの場合
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

動作確認

$ sudo 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/

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

その他の設定

dockerコマンドをsudoなしで実行する方法をやっておくと使い勝手が良いと思います。

0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?