「さくらのVPS」に Docker Engine をインストールしてみました。

 

 

オフィシャルのドキュメントに沿って作業してみました。やはりこれが一番確実です。

 

インストール要件

Docker オフィシャルサイト

Docker オフィシャルサイト

 

OS 要件

64bit 版の OS で以下のバージョンに対応しています。

  • Ubuntu 20.04 LTS
  • Ubuntu 19.10
  • Ubuntu 18.04 LTS
  • Ubuntu 16.04 LTS

今回は、 さくらVPS 上の Ubuntu 19.10 (eoan) で実行してみます。

 

古いバージョンをアンインストールする

古い Docker をインストールしている場合は、一旦アンインストール。次のコマンドで確認する。

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

今回は、なにもインストールされていないので、この部分はOK。

 

ストレージドライバ

Ubuntu の Docker Engine は次のストレージドライバをサポートしており、デフォルト以外のストレージドライバを使いたい場合は別途設定が必要。

  • overlay2 (デフォルト)
  • aufs
  • btrfs

ちょっとこの辺は違いがよくわかってないのでデフォルトのままで。

 

インストール

インストール方法

  1. Docker のリポジトリを設定してインストールする方法。これが一番オススメとのこと。
  2. DEB パッケージを取得して、手動でインストール、アップデートする方法。インターネットから隔離されたシステム向け?
  3. スクリプトを用いて最新の開発版 Docker Engine をインストールする。テスト環境や開発環境向け。

これはやはり、1. で良いと思います。

 

リポジトリを構成

apt コマンドでパッケージ情報を更新し、必要なパッケージをインストールします。

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

次のように表示されれば 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]

 

ソースリストに、Docker の公式リポジトリを追加。

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

$(lsb_release -cs) の部分はコードネームがわかってれば、eoan とか focal でも可。

 

Docker のインストール

続いて、Docker Engine をインストール。

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

 

インストールが出来ているかどうかの確認には、次のコマンドを実行します。

sudo docker run hello-world

 

次のように表示されたらOK。

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:d58e752213a51785838f9eed2b7a498ffa1cb3aa7f946dda11af39286c3db9a9
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/

 

まとめ

意外とすんなりいけましたね。

Windows 10 にも、Docker Desktop をインストールしたのですが、こちらは Hyper-V が噛んでいるのでホスト側に仮想環境のサポートが必要で、仮想マシン上で動いている Windows に Docker をインストールすることは出来ませんが、Linux の場合は VPS のような仮想マシン上でもインストールできます。

今後、すこしづつ Docker の知識を高めていきたいと思います。

 

関連リンク


 

 
カテゴリー: Linuxubuntu

zaturendo

中小企業社内SE。

0件のコメント

コメントを残す

アバタープレースホルダー

メールアドレスが公開されることはありません。 が付いている欄は必須項目です