Dockerを試す

Dockerはコンテナ型の仮想技術。むかしSolarisでもSolarisコンテナってのがあったな。いまもあるんだろうか。

インストール

RHELだとyum一発でインストールできる。

まずリポジトリを追加。

# wget -P /etc/yum.repos.d http://www.hop5.in/yum/el6/hop5.repo

でもってyumでインストール。

# yum install docker-io

さっそく使ってみる

dockerのバージョンをしらべる。

# docker version
Client version: 1.5.0
Client API version: 1.17
Go version (client): go1.3.3
Git commit (client): a8a31ef/1.5.0
OS/Arch (client): linux/amd64
FATA[0000] Get http:///var/run/docker.sock/v1.17/version: http: error connecting to proxy http://localhost:2002/: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS? 

なんだかエラーがでた。ググると、dockerのサービスが上がってないからだそうで。デーモンが必要なのか。

デーモンを上げる

# /etc/init.d/docker start
Starting docker:	                                   [  OK  ]

恒常的に使うならserviceにいれとかないと。

もう一度

# docker version
Client version: 1.5.0
Client API version: 1.17
Go version (client): go1.3.3
Git commit (client): a8a31ef/1.5.0
OS/Arch (client): linux/amd64
FATA[0000] Error response from daemon: 404 page not found 

馴染み深い404エラーだと。あーdaemonがproxyを認識していないのか。
どうやるんだ。。

プロクシの設定をいれてやる

この環境ではhttp,httpsはプロクシ経由。ということで/etc/sysconfig/dockerに以下の設定を入れる。

export http_proxy=http://localhost:2002/
export https_proxy=http://localhost:2002/
export no_proxy=/var/run/docker.sock,localhost,127.0.0.1

localhost:2002は適当に変更。sshのリバースプロクシで自端末のsquidを見せています。

これで動作するみたい。

イメージをpullしてみる。

# docker pull rhel
Pulling repository rhel
e3c92c6cff35: Download complete 
Status: Downloaded newer image for rhel:latest
#

おお、なんかダウンロードしてきた。
ダウンロードしたイメージをみてみる。

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
rhel                latest              e3c92c6cff35        3 weeks ago         158.2 MB
rhel                7.1-9               e3c92c6cff35        3 weeks ago         158.2 MB

ふーむ、動かして平気かなぁ。