Ubuntu 15.10 にDockerを入れる。

Dockerを使ってみることにした。
ちなみにWin9上のVirtualBox上のUbuntu15.10上でDockerしている。

※下にありますが、Ubuntu14と15で設定の仕方が変わっているので皆さん注意しましょう。

14の頃の情報でaptでInstallすると古いものが入るといううわさがあったので調べてみたら1.6は入っている模様

$ sudo apt-cache policy docker.io
docker.io:
  インストールされているバージョン: (なし)
  候補:               1.6.2~dfsg1-1ubuntu4
  バージョンテーブル:
     1.6.2~dfsg1-1ubuntu4 0
        500 http://jp.archive.ubuntu.com/ubuntu/ wily/universe amd64 Packages

とはいえ、最新でもないので本家にしたがってインストールする。
docs.docker.com

$ 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||<

/etc/apt/sources.list.d/docker.list
を開いて、以下を追記
>||
deb https://apt.dockerproject.org/repo ubuntu-wily main
$ sudo apt-get update
$ sudo apt-get purge lxc-docker
$ apt-cache policy docker-engine
docker-engine:
  インストールされているバージョン: (なし)
  候補:               1.11.1-0~wily
  バージョンテーブル:
     1.11.1-0~wily 0
        500 https://apt.dockerproject.org/repo/ ubuntu-wily/main amd64 Packages
     1.11.0-0~wily 0
        500 https://apt.dockerproject.org/repo/ ubuntu-wily/main amd64 Packages
     1.10.3-0~wily 0
        500 https://apt.dockerproject.org/repo/ ubuntu-wily/main amd64 Packages
・・・・・・

新しくなりました。
で、後はインストール

$ apt-get install docker-engine
$ docker --version
Docker version 1.11.1, build 5604cbe

Proxyの設定

以下を編集して
/etc/default/docker
export http_proxy="http://proxy.example.com:3128/"
的な感じでProxyを追加して
sudo service docker restart

これをやってから

お約束のハローワールド

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository docker.io/library/hello-world
docker: Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/hello-world/images. You may want to check your internet connection or if you are behind a proxy..
See 'docker run --help'.

となぜかhttps://index.docker.io/につながらない。。。
wgetすればうまくつながるので/etc/default/dockerの中身をうまく読めていない模様。。。

しかしいくらサービスを再起動しても、うまくいかない。。。
にゃんでやーーーー

sh -x /etc/init.d/docker restart

としてもそもそもの設定を読み込んでいない。
とおもっていろいろ調べていたら
Ubuntu 15.04では、systemdになっているので手順がかわっとる。
docs.master.dockerproject.org


Ubuntu14まではUpstartだったので上記手順でよかったのがかわったのですね。。。
こりゃなかなか気づかないわ。

手順にしたがってProxy設定を入れる

$ sudo mkdir /etc/systemd/system/docker.service.d
$ sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf 
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"

で保存して再起動。

$ sudo systemctl daemon-reload
$ sudo systemctl show --property=Environment docker
$ sudo systemctl restart docker

さて心して再起動。

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
4276590986f6: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:4f32210e234b4ad5cac92efacc0a3d602b02476c754f13d517e1ada048e5a8ba
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/

やっとできた。
本筋じゃないところではまると心折れるね