UbuntuへのDockerインストール方法

コンテナ技術 コンテナ技術

この記事の内容

この記事では、UbuntuにDokcerをインストールする方法を記載します。

UbuntuはUbuntu Bionic 18.04 (LTS)を使用しています。

基本的に、以下ページの公式の方法に基づいて、インストールを進めます。

Install Docker Engine on Ubuntu
Jumpstart your client-side server applications with Docker Engine on Ubuntu. This guide details prerequisites and multip...

インストール手順

apt のパッケージインデックスを更新し、apt が HTTPS 経由でリポジトリを使用できるようにパッケージをインストールします。

sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

Dockerの公式GPGキーを追加します。

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

フィンガープリント 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 のキーをが追加されていることを確認するために、最後の 8 文字を検索してみます。

sudo apt-key fingerprint 0EBFCD88

以下の様に、追加されていればOKです。

pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

aptコマンド用のリポジトリを設定します。dockerではstable、edge、testが公開されていますが、ここでは安定板のstableを使用します。

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"

aptパッケージのインデックスを更新し、最新版のDocker Engineとcontainerdをインストールします。

sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io

hello-worldのDockerイメージを実行して、正しくインストールできていることを確認します。

sudo docker run hello-world

コメント