因為目前1.8以上的docker最低要求是3.10的Linux內核,而我的內核版本遠低於此。
1 [root@localhost home]# uname -r 2 2.6.32-754.11.1.el6.x86_64
鑒於我的vm上有一堆的dependency,並且沒有太多的時間來把內核升級,所以只能咬牙在redhat6的環境下裝docker,先把不能把代碼mount到另外一台ubuntu上跑unittest這個事情給解決了(這里我想吐槽管殺不管埋的IT一百遍)。
docker主要依賴於CE(社區版,一般已經很夠用了),它的主要依賴包如下:(這個是1.7版本的,從網上看到的)
lxc-libs-1.0.9-1.el6.x86_64.rpm lua-alt-getopt-0.7.0-1.el6.noarch.rpm lua-filesystem-1.4.2-1.el6.x86_64.rpm lua-lxc-1.0.9-1.el6.x86_64.rpm lxc-1.0.9-1.el6.x86_64.rpm docker-io-1.7.1-2.el6.x86_64.rpm device-mapper-libs-1.02.117-12.el6.i686.rpm device-mapper-libs-1.02.117-12.el6.x86_64.rpm
但是我想用yum下載並安裝,所以為了以防萬一,我先裝了個epel-release。EPEL (Extra Packages for Enterprise Linux)是基於Fedora的一個項目,為“紅帽系”的操作系統提供額外的軟件包,適用於RHEL、CentOS和Scientific Linux.
1 [root@localhost Downloads]# yum -y install epel-release
2 Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
3 Updating certificate-based repositories.
4 Unable to read consumer identity
5 epel | 4.7 kB 00:00
6 itaas | 2.0 kB 00:00
7 itaas-extras | 1.8 kB 00:00
8 itaas-optional | 2.0 kB 00:00
9 itaas-supplementary | 2.0 kB 00:00
10 Setting up Install Process
11 Package epel-release-6-8.noarch already installed and latest version
12 Nothing to do
安裝成功后,yum的源可以看到
1 [root@localhost Downloads]# yum repolist
2 Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
3 Updating certificate-based repositories.
4 Unable to read consumer identity
5 repo id repo name status
6 epel Extra Packages for Enterprise Linux 6 - x86_64 12,503
7 itaas itaas 20,720
8 itaas-extras itaas extras yum repo 97
9 itaas-optional itaas optional yum repo 11,997
10 itaas-supplementary itaas supplementary yum repo 896 11 repolist: 46,213
查找docker相應的依賴包
1 [root@localhost etc]# yum search docker 2 Loaded plugins: product-id, refresh-packagekit, security, subscription-manager 3 Updating certificate-based repositories. 4 Unable to read consumer identity 5 ============================================================================================== N/S Matched: docker =============================================================================================== 6 docker-io-fish-completion.x86_64 : fish completion files for docker 7 docker-io-logrotate.x86_64 : cron job to run logrotate on docker containers 8 docker-io-vim.x86_64 : vim syntax highlighting files for docker 9 docker-io-zsh-completion.x86_64 : zsh completion files for docker 10 fedora-dockerfiles.x86_64 : Example dockerfiles to assist standing up containers quickly 11 golang-github-docker-libtrust-unit-test.x86_64 : Unit tests for golang-github-docker-libtrust package 12 golang-github-docker-spdystream-unit-test.x86_64 : Unit tests for golang-github-docker-spdystream package 13 golang-github-fsouza-go-dockerclient-devel.noarch : Client for the Docker remote API 14 golang-github-fsouza-go-dockerclient-unit-test.x86_64 : Unit tests for golang-github-fsouza-go-dockerclient package 15 imagefactory-plugins-Docker.noarch : Cloud plugin for Docker 16 python-docker-py.x86_64 : An API client for docker written in Python 17 python-docker-registry-core.noarch : Core package for docker-registry (drivers) developers 18 python-dockerfile-parse.noarch : Python library for Dockerfile manipulation 19 docker.x86_64 : KDE and GNOME2 system tray replacement docking application 20 docker-io.x86_64 : Automates deployment of containerized applications 21 docker-io-devel.x86_64 : A golang registry for global request variables (source libraries) 22 golang-github-docker-libcontainer.x86_64 : Configuration options for containers 23 golang-github-docker-libcontainer-devel.x86_64 : Configuration options for containers 24 golang-github-docker-libtrust-devel.noarch : Library for managing authentication and authorization 25 golang-github-docker-spdystream-devel.noarch : A multiplexed stream library using spdy 26 27 Name and summary matches only, use "search all" for everything.
安裝docker必須的依賴包,以為有些依賴包之間也存在依賴關系,所以有些裝完,被依賴的包也就順便一起裝了。
1 [root@localhost etc]# yum install -y docker 2 [root@localhost etc]# yum install -y lua-lxc.x86_64 3 [root@localhost etc]# yum install -y lxc.x86_64 4 [root@localhost8 etc]# yum install -y docker-io.x86_64 5 [root@localhost etc]# yum install -y device-mapper-libs.i686 6 [root@localhost etc]# yum install -y device-mapper-libs.x86_64
然后把docker的service打開,確認docker是否裝上了
1 [root@localhost docker]# service docker start 2 Starting docker: [ OK ] 3 [root@localhost docker]# docker info
這里需要注意一下,因為是redhat6,所以只有service,沒有systemctl。這里還關系到另外一個問題,就是盡量不要把docker的存儲位置遷移。
目前網上所教的方法,有如下幾種:
1. 是把/var/lib/docker整個路徑下的文件都拷貝到其他位置,然后再軟鏈接回來。
2.是把/var/lib/docker整個路徑下的文件都拷貝到其他位置,然后修改docker.service,
- --graph=/data/docker:docker新的存儲位置
- --storage-driver=overlay : 當前docker所使用的存儲驅動
雖然這倆方法都挺好的,但是redhat6的service寫法於redhat7不同,並且我們這里裝的docker版本比較低,軟鏈接回來,有些路徑依舊不對,docker pull會不起作用,並且明面上不會有報錯。所以最好不遷移。