2017年3月28日火曜日

Ubuntu 16.04へのdocker-ceインストール

Docker公式リポジトリからのインストール

Ubuntu 16.04への最新版dockerをインストールする手順の備忘録です。構成管理が楽になるので、バイナリインストールでなく、パッケージ管理システム経由でのインストール手順を記載します。

リポジトリアクセスのためのパッケージ導入

Docker公式リポジトリにHTTPS経由でアクセスするために必要なパッケージをインストールします。
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

リポジトリ検証用の公開鍵導入

Dockerの公式GPG(GNU Privacy Guard)鍵を追加します。インターネットから入手したパッケージが正しい配布元からのものか検証するために用いられます。
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

パッケージ管理システムへのリポジトリ追加

stableリポジトリを追加します。edgeとstableの二種類のリポジトリがあり、edgeは月一のリリースでstableは四半期毎にリリースされる違いです。
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

パッケージ管理システムからのdocker-ceのインストール

$ sudo apt update && sudo apt install docker-ce

Dockerのインストール確認

以下のコマンドでテスト用のイメージをダウンロードし、それをコンテナ内で実行することができます。同じメッセージが出力されることで、インストールが成功したことがわかります。
$ sudo 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.
 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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/


0 件のコメント:

コメントを投稿