Fedora 27でのDocker CEのインストールについて

 Dockerとは?

すでにDockerを利用されている方も多いかと思いますが、改めて簡単にご紹介します。

Dockerは、2013年3月15日にサンタクララで開催されたPython Developers Conferenceで紹介されました。Dockerとは、コンテナ仮想化ツールです。

仮想化と言えばハイパーバイザ型(Hyper-VKVMXen)やホスト型(VMware PlayerやWindows Virtual PCVirtualBoxなど)があります。
しかし、この方式では、目的のアプリケーションとは関係のないサービスなども多数動作することになり、オーバーヘッドが大きく、リソースも無駄に多く必要になります。

一方Dockerは、Linuxのコンテナ技術を使ったもので、ホストマシンのカーネルを利用し、プロセスなどを隔離することで、独立したコンピュータ上で動作しているように振舞います。では、早速インストールしてみましょう。

 Dockerインストール

まず古いバージョンを削除します。dockerやdocker-engineと呼ばれる古いバージョンをアンインストールします。

$ sudo dnf remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine 

もし、インストールされていなければ、エラーが出ますが、特に問題ありません。

Docker Community Editionをインストールするために、stableレポジトリを追加します。

$ sudo dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo 

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

$ sudo dnf install docker-ce 

 Docker CEを起動し、 hello-worldイメージを起動し、問題なくインストールできたか確認します。下記のようなメッセージが表示されれば問題ありません。

$ sudo docker run hello-world

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.

 裏では、上記1から4のステップが実行されたことを表示しています。

 

このdockerというコマンドは、Go言語で記述されています。オープンソースなので、誰でも見ることできます。興味がある方は、https://github.com/docker/docker-ceからダウンロードしてみてください。

docker-ce]$ ls components/cli/cmd/docker/
docker.go docker_test.go docker_windows.go