CentOS7.x使用overlay2文件系統


當我查看docker詳細信息時會看到如下警告:

WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use.
         Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.

 

問題原因:

centos系統docker默認使用存儲驅動是devicemapper,而這種存儲驅動有兩種模式loop-lvm和direct-lvm,不巧默認又使用了比較低效的loop-lvm

 

解決方案一

使用direct-lvm,配置方式網上很多

 

解決方案二:

使用overlay文件系統

因為這個方案比較簡單,配置步驟如下:
1.加載overlay模塊

echo "overlay" > /etc/modules-load.d/overlay.conf
modprobe overlay
lsmod | grep over reboot

 

2.刪除docker配置信息

rm -rf /var/lib/docker

 

3.修改docker啟動參數

vim /usr/lib/systemd/system/docker.service
#ExecStart=/usr/bin/dockerd
ExecStart=/usr/bin/dockerd --storage-driver=overlay2 -g /opt/docker

 

4.重啟docker

systemctl daemon-reload
systemctl restart docker

 

5.檢測

#docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 18.06.1-ce
Storage Driver: overlay
Backing Filesystem: xfs
Supports d_type: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-862.14.4.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 24
Total Memory: 125.7GiB
Name: centos7-hk122
ID: 3AG5:7RUW:OZZF:ZW7Q:FRMQ:AB3M:AQWX:YIJR:H63R:JI5R:DKGS:HDUM
Docker Root Dir: /opt/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

不再彈出警告信息

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM