LoginSignup
5
5

More than 5 years have passed since last update.

vagrant 上の Ubuntu14.04 trusty LTS に Docker をインストール

Last updated at Posted at 2016-06-22

手っ取り早くインストールしたい人へ

↓のシェルスクリプトを実行しましょう

setup.bash
#!/bin/bash

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get purge lxc-docker
sudo apt-cache policy docker-engine
sudo apt-get install linux-image-extra-$(uname -r) -y
sudo apt-get install apparmor
sudo apt-get install docker-engine -y

環境

vagrant上で仮想マシンを作ります
(vagrantじゃなくても既にUbuntu14.04 trusty LTSを作ってる人は読み飛ばしてね)

vagrant init ubuntu https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box

ここで直接ダウンロードしてもOKですよ
Official Ubuntu 14.04 daily Cloud Image amd64 (Development release, No Guest Additions)と書いてあるものです

作ったマシンを立ち上げます

vagrant up

立ち上げたマシンにログインします

vagrant ssh

Dockerをインストール

取りあえずupdate

sudo apt-get update

CA証明証をインストール(httpsが使えないとダメだよ)

sudo apt-get install apt-transport-https ca-certificates

新しいGPG鍵を追加

sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

/etc/apt/sources.list.d/docker.listに
「deb https://apt.dockerproject.org/repo ubuntu-trusty main」
と記述(なければファイルを作成する)

sudo echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list

もう一度update

sudo apt-get update

もしlxc-dockerがあれば削除

sudo apt-get purge lxc-docker

APTが正しいレポジトリから入手していることを確認

apt-cache policy docker-engine

linux-image-extraをインストールすることが推奨されているので,OSのバージョンに応じてインストール

apt-get install linux-image-extra-$(uname -r) -y

Ubuntu 14.04 と 12.04 ではapparmorが必要なのでインストール

apt-get install apparmor

Dockerをインストール

sudo apt-get install docker-engine -y

Dockerが適切に使えるかを確認
(すでにDockerが起動してるはずなので,起動のコマンドは不要)

sudo docker run hello-world

すると↓のような実行結果が出力されると思います

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
a9d36faac0fe: Pull complete
Digest: sha256:e52be8ffeeb1f374f440893189cd32f44cb166650e7ab185fa7735b7dc48d619
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 Hub account:
 https://hub.docker.com

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

起動・終了

起動

sudo service docker start

終了

sudo service docker stop
5
5
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
5
5