[root@localhost ~]# docker version Client: Version: 1.9.1 API version: 1.21 Package version: docker-common-1.9.1-40.el7.centos.x86_64 Go version: go1.4.2 Git commit: ab77bde/1.9.1 Built: OS/Arch: linux/amd64 Server: Version: 1.9.1 API version: 1.21 Package version: docker-common-1.9.1-40.el7.centos.x86_64 Go version: go1.4.2 Git commit: ab77bde/1.9.1 Built: OS/Arch: linux/amd64
啓動 docker 發現以下日誌;
linux
Jun 22 18:00:11 localhost systemd: docker-storage-setup.service: main process exited, code=exited, status=1/FAILURE面試
Jun 22 18:00:11 localhost systemd: Failed to start Docker Storage Setup.docker
Jun 22 18:00:11 localhost systemd: Unit docker-storage-setup.service entered failed state.centos
Jun 22 18:00:11 localhost systemd: docker-storage-setup.service failed.bash
分析:說是 docker-storage-setup.service 不能運行。這個服務呼叫 docker-storage-setup 命令,而這個命令app
是要看 /etc/sysconfig/docker-storage-setup 文件的。ide
man docker-storage-setup:STORAGE_DRIVER: 默認便是"devicemapper",這也正是咱們須要的,其餘的還有"" 空值,和 "overlay", devicemapper 是依賴於 lvm 的,在早一點的 centos7 上就是如此,在這一版(可能稍新)就會報錯。ui
後面試了VG 跟 DEVS 選項,仍然不行。google
百度一下錯誤,沒有此相關的,有說數據卷建成後,報錯數據滿了致使報錯的。centos7
google不也,bing 了下,找到了幾個相關的問題:
1. 仍是 /etc/sysconfig/docker-storage-setup 的緣由致使的。
2. /etc/sysconfig/docker-storage 這個文件的內容是不能寫的,是要用docker-storage-setup 生成的,而這個命令是要讀取 /etc/sysconfig/docker-storage-setup 這個文件的配置的。
3.搜索到了這樣一句話:
Also, in a cloud (OpenStack/AWS/etc.) scenario with the devicemapper backend, docker-storage-setup can also expand the root volume group to fill the space allocated for the root disk if GROWPART=true is set.
大意是使用devicemapper 選項的話,那麼要使用 GROWPART = true 選項來啓用 lvm 的調整。而默認這個選項是 false的。
而這個選項的開啓要依賴 /usr/bin/growpart 命令。
解決:
1.中止docker 服務
2.刪除 /var/lib/docker 目錄
3.在 /etc/sysconfig/docker-storage-setup 文件裏添加
STORAGE_DRIVER="devicemapper"
GROWPART="true"
4./usr/bin/growpart 命令用 yum search 搜索結果爲 cloud-utils-growpart-0.27-20.el7.centos.x86_64。yum 安裝此包.
5.啓動docker, 查看日誌信息已經正常,查看 /etc/sysconfig/docker-storage 文件 ,已經有了如下內容:
DOCKER_STORAGE_OPTIONS="--storage-driver devicemapper --storage-opt dm.fs=xfs --storage-opt dm.thinpooldev=/dev/mapper/centos-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true "
雖然還有關於防火牆的報錯,可是那是另外的緣由形成的。這個問題已經OK了
notice:
1.STORAGE_DRIVER="devicemapper" 是須要 lvm 的支持的。最好是在裝系統時 就是裝在 lvm 上的。不然,那就要新建一個 vg 好比 "centos", 而後在 /etc/sysconfig/docker-storage-setup 裏再加上
VG="centos"
這個也已經驗證過了。
2.剛開始發現這個錯誤,是由於啓用 -v /root/ldap:/var/lib/ldap 數據卷後,在container居然沒法讀寫/var/lib/ldap 目錄。而後看日誌才發現了這個錯誤。把這個問題解決後,發現依然沒法讀寫. 又百了下,原來是 selinux 沒關致使的。
# setenforce 0
成功解決問題。那麼你可能要說,是否是不解決上面的問題,關掉selinux 也沒問題呢?我以爲只要我發現這個報錯了,我就會解決的,也許如今沒影響,可是 docker 的存儲(數據卷)是重要的功能,總會由於此報錯而產生其餘的錯誤的。
3.試過另一個選項, STORAGE_DRIVER="overlay", 這樣的話,也不報錯了,並且在 /var/lib/docker 目錄下的文件也發生了變化。具體的做用還不清楚。