docker 存储overlay升级到overlay2
The overlay2 driver is supported for Docker EE and recommended for Docker CE.
Version 4.0 or higher of the Linux kernel. If you use an older kernel, you will need to use the overlay
driver, which is not recommended.
The following backing filesystems are supported:
ext4 (RHEL 7.1 only)
xfs (RHEL 7.2 and higher), but only with d_type=true enabled. Use
xfs_info to verify that the ftype option is set to 1. To format an xfs
filesystem correctly, use the flag -n ftype=1.
Changing the storage driver will make any containers you have already created inaccessible on the
local system. Use docker save to save containers, and push existing images to Docker Hub or a
private repository, so that you not need to re-create them later.
Configure Docker with the overlay or overlay2 storage driver
1. Stop Docker.
$ sudo systemctl stop docker
2. Copy the contents of /var/lib/docker to a temporary location.
$ cp -au /var/lib/docker /var/lib/docker.bk
3. If you want to use a separate backing filesystem from the one used by /var/lib/, format the
filesystem and mount it into /var/lib/docker. Make sure add this mount to /etc/fstab to make it
permanent.
4. Edit /etc/docker/daemon.json. If it does not yet exist, create it. Assuming that the file was
empty, add the following contents.
{
"storage-driver": "overlay2"
}
If you need to use the legacy overlay driver, specify it instead.
To use overlay2 on CentOS (Docker CE only), you must also set the storage option
overlay2.override_kernel_check. In this case the daemon.json would look like this:
{
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
1. Start Docker.
$ sudo systemctl start docker
2. Verify that the daemon is using the overlay/overlay2 storage driver. Use the docker info command
评论0