LoginSignup
3
1

More than 5 years have passed since last update.

Ubuntu16.04 LTSにDocker CEをインストールする。

Posted at

Docker CE

Docker EE(Enterprise Edition)の登場によって、無料版はDocker CE(Community Edition)として登場しました。
自宅サーバのリプレイスに伴って、Docker CEのインストールを行います。
基本的な手順は下記を参考にします。
https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/

Dockerインストール前にやること

  • aptのインデックスを最新にします。
$sudo apt update
  • httpsでapt を使えるようにします。
$sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
  • Dockerの公式GPG keyを追加
$curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • fingerprintを確認する。
$sudo apt-key fingerprint 0EBFCD88

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
  • repositoryの追加
$sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  • apt updateする
$sudo apt-get update

Docker CEのインストール

準備が終わっていれば、下記コマンドでDockeCEのインストールを行います。

$sudo apt-get install docker-ce

インストール後の確認

$sudo docker --version

Docker version 17.06.0-ce, build 02c1d87

試しにhello-worldコンテナを起動

$sudo docker run hello-world

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

Hello from Dockerが表示されれば、DockerCEのインストールとDocker Engine上でhello-worldコンテナが動いており、インストールは完了です。

おまけ

もうhello-worldコンテナがいらないときは下記で削除します

$ sudo docker rmi -f hello-world
Untagged: hello-world:latest
Untagged: hello-world@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f
Deleted: sha256:1815c82652c03bfd8644afda26fb184f2ed891d921b20a0703b46768f9755c57

これで作業は完了です。

3
1
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
3
1