LoginSignup
12
15

More than 5 years have passed since last update.

UbuntuにDockerを入れる

Last updated at Posted at 2018-03-25

Lubuntu にDocker をインストールする手順をまとめた。

この記事を読む対象の人

  • Linux を触ったことがある人(現在進行形で触っている人)
  • Docker を使ってみたいと思っている人

今回のOS環境

  • Lubuntu 16.04 (Ubuntu でも同様の手順でインストール可能)

インストール手順

インストールは、全てターミナルから行う。
インストールを始める前に、パッケージのアップデートをしておく。

sudo apt-get update

HTTPS経由でリポジトリを取得できるようにする。
※ インストールには、curl コマンドを使用するので、curl をインストールしておくこと。curl については説明を省略。

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

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

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

公開鍵のフィンガープリントを確認。

sudo apt-key fingerprint 0EBFCD88

apt コマンド用のリポジトリの設定を行う。

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

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

sudo apt-get update
sudo apt-get install docker-ce

hello-world イメージを実行して、Docker が正しくインストールされているか確認する。
下記のようになれば成功。

sudo docker run hello-world

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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

sudo なしでDocker を動かすために

このままだと、いざDocker を動かすときに、いちいちdockerコマンドの前にsudoをつけて実行しないといけないのは面倒なので、sudo なしでDocker を動かせるようにする。

docker という名前のグループを作成し、そのグループにユーザを所属させる。

sudo groupadd docker
sudo gpasswd -a [username] docker

参考URL

記事の大体は公式サイトから。
https://docs.docker.com/install/linux/docker-ce/ubuntu/#set-up-the-repository

とてもわかりやすかったです。ありがとうございました。
http://www.atmarkit.co.jp/ait/articles/1701/30/news037.html
https://qiita.com/tkyonezu/items/0f6da57eb2d823d2611d
https://qiita.com/DQNEO/items/da5df074c48b012152ee

12
15
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
12
15