Docker storage driver changed from overlay to overlay2
System Information # cat / etc/redhat-releaseCentOS Linux release 7.2.1511 (Core) # uname-r3.10.0-514.26.2.el7.x86_64
If you need to upgrade the system kernel version, see the Centos system kernel upgrade method for details.
If you upgrade to the CentOS7 version, the main steps are:
(1) key# rpm imported into elrepo-- import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org (2) To install ELRepo for RHEL-7, SL-7 or CentOS-7# rpm-Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm (3) there are ml and lt kernels in the elrepo source of yum, where ml (mainline) is the latest version of the kernel. Lt is a long-supported kernel: # yum-- enablerepo=elrepo-kernel-y install kernel-lt (4) modify the grub.conf file vim / etc/grub.conf:default=0 (5) restart the system to take effect: # reboot View docker version and other information # docker info Server Version: 18.09.0 / / or 17.09.0-ce version Storage Driver: overlay. Why use overlay2
There are a lot of online resources about the difference between overlay and overlay2, which will not be introduced as a key point here.
The reason for upgrading to overlay2 is that we often encounter such problems in our work:
Step 1: FROM million12/nginx-php:latest-- > 09c053597ddaStep 2: COPY etc/docker-jenkins/default.conf / etc/nginx/hosts.d/default.conf-- > Using cache--> 26a29dd01af3Step 3: COPY app / data/www/appINFO [0012] link / var/lib/docker/overlay/99380f87e1572466529c4f668b5e79fe711496e985d313cc0d2f45bfdbdb3969/root/var/lib/yum/yumdb/p/939d2078d64d51ff7ad16150745e94a26085bc93-php70-php-opcache-7.0.11-1.el7.remi-x86_64/checksum_type / var/lib/ Docker/overlay/9ac18f869f20ba8ba29d2a16f00f2ce6ff1c6d0d1a40192a0efb8933c8ad1c45/tmproot958106287/var/lib/yum/yumdb/p/939d2078d64d51ff7ad16150745e94a26085bc93-php70-php-opcache-7.0.11-1.el7.remi-x86_64/checksum_type: too many links
Using overlay2 can solve this "too many links" problem very well.
To solve the "too many links" problem above, you can use the following two methods:
(1) temporary method: delete useless images and exited containers regularly, and use docker system prune.
(2) permanent method: upgrade the storage driver from overlay to overlay2.
Change the Docker storage driver from overlay to overlay2
Pay attention to ⚠️ before operation: before docker images will be lost, previously running docker container service will be lost (docker ps), please make a backup of the data before performing the following steps!
The specific steps are as follows:
(1) close the running docker service # systemctl stop docker (2) add the daemon.json file # echo "{" storage-driver ":" overlay2 "," storage-opts ": [" overlay2.override_kernel_check=true "]," registry-mirrors ": [" https://xxx.mirror.aliyuncs.com"], "live-restore": false} "> > / etc/docker/daemon.json (3) start the docker service # systemctl start docker