LoginSignup
10
6

More than 5 years have passed since last update.

Install Docker on Linux Mint 19 (Tara).

Last updated at Posted at 2018-10-07

Linux Mint 19 に Docker をインストール

本記事ではVirtualBoxで構築されたLinux Mintの仮想環境にDockerをインストールします。
仮想環境は構築済みを想定しているので、本記事は仮想環境の構築等には触れません。
そのため仮想環境にインストールと言っても、実機環境へのインストールとあまり変わらないと思います。

またインストールするDockerは無償版のdocker-ceとなります。
商用版のDockerも存在し、こちらはdocker-eeと呼ばれます。

略称の補足
ce : Community Edition
ee : Enterprise Edition

実行環境

Host OS

  • Windows10
  • VirtualBox 5.2.16

Gesut OS

  • Linux Mint 19 (Tara) Cinnamon 64bit
  • kernel 4.15.0-20-generic

インストール手順

DockerをLinux Mintにインストールするまでの手順です。

1.apt-getコマンド拡張

apt-getコマンドをhttps経由で使用できるように設定します。 1

terminal
$ sudo apt-get install apt-transport-https \
  ca-certificates curl software-properties-common

2.GPGキー追加

正しい配布先からパッケージを入手できるようにDockerのGPGキーを追加します。 1 2

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

3.フィンガープリント確認

正しい配布先からパッケージを入手できるか確認します。 1

terminal
$ sudo apt-key fingerprint 0EBFCD88

実行結果 1
pub uid sub が下記のようになっていれば、正しい配布先からパッケージを入手できます。

terminal
pub   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22

4.Dockerリポジトリ追加

apt-getコマンドでインストールができるようにdockerリポジトリを追加します。
公式ガイドラインに記載されている以下のコマンドではエラーとなります。1

terminal
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

エラーになる理由としては$(lsb_release -cs)コマンドで返ってくる値がTaraとなってしまい、
Taraに対応するリポジトリ存在しないためエラーとなります。

そのためコマンドの修正が必要になります。
Linux Mint 19 (Tara)Ubuntu 18.04 LTS (Bionic)をベースとしているため、
以下のように$(lsb_release -cs)bionicに修正して実行します。

terminal
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

Dockerリポジトリにはstableの他にedgetestが存在するので、
stableのリポジトリが存在しない場合はedgetestを試してみてください。

5.Dockerインストール

Dockerをインストールします。
パッケージを更新します。

terminal
$ sudo apt-get update

docker-ceをインストールします。

terminal
$ sudo apt-get install docker-ce

指定バージョンのDockerインストール

指定バージョンのdocker-ceをインストールする場合は、
まずリポジトリからインストールできるdocker-ceのバージョンを確認します。 1

terminal
$ apt-cache madison docker-ce

実行結果 1
以下のようにバージョンが表示されます。
インストールコマンドに使用するバージョンは18.03.0~ce-0~ubuntuの部分となります。 1

terminal
$ docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

指定バージョンdocker-ceをインストールします。 1

terminal
$ sudo apt-get install docker-ce=<VERSION>

<VERSION>を先程の18.03.0~ce-0~ubuntuに置き換えることで
指定バージョンのDockerがインストールできます。

terminal
$ sudo apt-get install docker-ce=18.03.0~ce-0~ubuntu

6.インストール確認

正常にインストールされているか動作確認をします。 1

terminal
$ sudo docker run hello-world

実行結果
以下のようにHello from Docker!と表示されていれば正常にインストールされています。 1

terminal
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete 
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/

参考

https://docs.docker.com/install/linux/docker-ce/ubuntu/#os-requirements
https://qiita.com/Mokkeee/items/6a1fa26916bd7b45bda7


  1. docker docs Guides
    Get Docker CE for Ubuntu からコマンドを抜粋 

  2. GPGは[GnuPG](GNU Privacy Guard)で生成された公開鍵
    パッケージが正しい配布先から入手されたかなどをチェックする 

10
6
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
10
6