LoginSignup
4
2

More than 5 years have passed since last update.

CentOS 6.6でDocker

Posted at

CentOS 6で、Dockerを使いたいという人が多くて、少し調べてみました。

サポートについて

CentOS 6上、Dockerを使用する場合、DockerにしてもRedHatにしても正式にサポートしていないので注意する必要があります。

  • DockerではCentOS6は正式にサポートしていない

昔は、CentOS6の記載があったのですが、なくなっています。
https://docs.docker.com/installation/centos/

Docker is supported on the following versions of CentOS:

CentOS 7.X

Installation on other binary compatible EL7 distributions such as Scientific Linux might succeed, but Docker does not test or support Docker on these distributions.

Red Hat Enterprise Linux 6 introduced Linux Container support as a technical preview.

さらに注意事項

まずは中井さんのページを見てください。
 第43回 「Dockerイメージ」のポータビリティとLinuxカーネルのABI (中井悦司)

Linuxのコンテナが異なるバージョンで動く理由は、LinuxのABI(Application Binary Interface)のおかげのようです。厳格にABIの変更が禁止されているので、新しいカーネルの開発は古いカーネルを継承して作られているため、古いカーネルのシステムコールは動作するようになっているということです。

逆に考えれば、古いカーネル上で新しいカーネルも動くかもしれませんが、新しい機能の部分はうまく動作しないということになります。

つまり、CentOS 6を使用する限りは、動作する可能性があるのは同バージョンか、あるいは下位のバージョンということになります。

インストール

epelのインストール

詳細は、EPELを見てください。

rpm -ihv https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm                                              
https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm を取得中
警告: /var/tmp/rpm-tmp.OdeNN6: ヘッダ V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
準備中...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

epelには、dockerとdocker-ioの2種類がありますが、以下の違いがあります。

# repoquery --list docker
/usr/bin/docker
/usr/share/doc/docker-1.5
/usr/share/doc/docker-1.5/COPYING
/usr/share/doc/docker-1.5/README

# repoquery --list docker-io
/etc/docker
/etc/rc.d/init.d/docker
/etc/sysconfig/docker
/etc/sysconfig/docker-network
/etc/sysconfig/docker-storage
/etc/udev/rules.d/80-docker.rules
/usr/bin/docker
/usr/libexec/docker
/usr/libexec/docker/dockerinit
...(略)

インストール

docker-ioをインストールします。

# yum install docker-io 
...
依存性を解決しました

===============================================================================================================================================
 パッケージ                       アーキテクチャ           バージョン                                          リポジトリー               容量
===============================================================================================================================================
インストールしています:
 docker-io                        x86_64                   1.5.0-1.el6                                         epel                      4.7 M
依存性関連でのインストールをします。:
 libcgroup                        x86_64                   0.40.rc1-15.el6_6                                   updates                   129 k
 lua-alt-getopt                   noarch                   0.7.0-1.el6                                         epel                      6.9 k
 lua-filesystem                   x86_64                   1.4.2-1.el6                                         epel                       24 k
 lua-lxc                          x86_64                   1.0.7-1.el6                                         epel                       15 k
 lxc                              x86_64                   1.0.7-1.el6                                         epel                      120 k
 lxc-libs                         x86_64                   1.0.7-1.el6                                         epel                      249 k
 xz                               x86_64                   4.999.9-0.5.beta.20091007git.el6                    base                      137 k
...
依存性関連をインストールしました:
  libcgroup.x86_64 0:0.40.rc1-15.el6_6                 lua-alt-getopt.noarch 0:0.7.0-1.el6         lua-filesystem.x86_64 0:1.4.2-1.el6        
  lua-lxc.x86_64 0:1.0.7-1.el6                         lxc.x86_64 0:1.0.7-1.el6                    lxc-libs.x86_64 0:1.0.7-1.el6              
  xz.x86_64 0:4.999.9-0.5.beta.20091007git.el6        

完了しました!

起動

それでは起動させましょう。停止状態になっているので、起動させましょう。

# chkconfig --list docker
docker          0:off   1:off   2:on    3:on    4:on    5:on    6:off

# service docker status
docker は停止しています

# service docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:                                           [  OK  ]

コンテナ起動

コンテナ起動します。もちろん、コマンドは同じです。

# docker run -it --name test01 centos:6 /bin/bash
Unable to find image 'centos:6' locally
Pulling repository centos
a005304e4e74: Download complete
f1b10cd84249: Download complete
fb9cc58bde0c: Download complete
Status: Downloaded newer image for centos:6  

確認

同じですね。

# lsblk 
NAME                                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0                                 7:0    0  100G  0 loop 
└─docker-253:0-264044-pool (dm-2)   253:2    0  100G  0 dm   
  ├─docker-253:0-264044-base (dm-3) 253:3    0   10G  0 dm   
  └─docker-253:0-264044-3eeef49defe35cf4b9b7c5988806b2a15678a15738e05a68e4d94655b9a204bb (dm-4)
                                    253:4    0   10G  0 dm   /var/lib/docker/devicemapper/mnt/3eeef49defe35cf4b9b7c5988806b2a15678a15738e05a68e
loop1                                 7:1    0    2G  0 loop 
└─docker-253:0-264044-pool (dm-2)   253:2    0  100G  0 dm   
  ├─docker-253:0-264044-base (dm-3) 253:3    0   10G  0 dm   
  └─docker-253:0-264044-3eeef49defe35cf4b9b7c5988806b2a15678a15738e05a68e4d94655b9a204bb (dm-4)
                                    253:4    0   10G  0 dm   /var/lib/docker/devicemapper/mnt/3eeef49defe35cf4b9b7c5988806b2a15678a15738e05a68e
sr0                                  11:0    1 1024M  0 rom  
sda                                   8:0    0   20G  0 disk 
├─sda1                                8:1    0  500M  0 part /boot
└─sda2                                8:2    0 19.5G  0 part 
  ├─vg_centos6-lv_root (dm-0)       253:0    0 17.5G  0 lvm  /
  └─vg_centos6-lv_swap (dm-1)       253:1    0    2G  0 lvm  [SWAP]
4
2
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
4
2