EatSmartシステム部ブログ

ウェブサイトの開発や運営に関する情報です。

CentOS6.4にDockerをインストール

先日パーティションを拡張したサーバーに色々とインストールしようと思っていたのですが、実はサーバーがCentOS6.4だったため、今後移行する事も考え仮想化したゲストOSの上に構築しようと考えました。

で、色々調べたところ、CentOS6.4でDockerが使える?らしいので、Dockerの環境を構築することにしました。

Dockerのインストール

先ほどのリンク先を参考に

# rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
# yum install -y http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: www.ftp.ne.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.jp

Complete!

 としてからの

# yum install -y docker-io
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/metalink | 5.9 kB 00:00
* base: www.ftp.ne.jp
* epel: ftp.riken.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.jp

Complete!

で、インストールは出来たようです。

まずは以下で起動します。

# /etc/init.d/docker status
docker は停止しています
# /etc/init.d/docker start
Starting cgconfig service: [ OK ]
Starting docker: [ OK ]

無事起動できたようです。

Dockerを起動できません

しかし

# docker run hello-world

Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
# docker -d
WARN[0000] You are running linux kernel version 2.6.32-358.23.2.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0.
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
docker: relocation error: docker: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference

 と、カーネルのバージョンの問題で、起動できていないようです。

試しに

# yum -y install libdevmapper.so.1.02
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: www.ftp.ne.jp
* epel: ftp.kddilabs.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.jp

 Complete!

としたのですが、

# /etc/init.d/docker start

Starting docker: [ OK ]

# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from hello-world
3f12c794407e: Pull complete
975b84d108f1: Pull complete
Digest: sha256:c96eeb93f2590858b9e1396e808d817fa0ba4076c68b59395445cb957b524408
Status: Downloaded newer image for centos:latest
Error response from daemon: Cannot start container b0468016e12ee2aa8b141f83537154c0941dc66e2ecd37a6b3418c4261a9791c: no such file or directory

となってしまいます。 

OSのアップデート

仕方が無いので、以下のようにCentOSをアップデート、

# yum clean all
# yum -y upgrade

としてから

# shutdown -r now

# uname -a

Linux chromium.eatsmart.lan 2.6.32-573.8.1.el6.x86_64 #1 SMP Tue Nov 10 18:01:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux  

 で、無事にアップデートできました。

#まだDockerの要求するバージョンには程遠いですが…

動きました

やっと無事にDockerを動かすことができました。

# 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.
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/userguide/ 

 で、Dockerで何を動かすんだっけ?