Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What `native overlay diff` mean in overlay2 storage driver?

Tags:

docker

I experienced that a lower layer(diff) of an image which is associated with the running container are removed. (So some files in the container is removed)

I think 'Native Overlay Diff' option from docker info is quite suspicious.

My docker info like below:

$ docker info
...
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
 Native Overlay Diff: false
...

Do you guys know the exact meaning of 'Native Overlay Diff'?

like image 754
SunghoMoon Avatar asked Oct 17 '17 10:10

SunghoMoon


People also ask

What is overlay storage driver?

OverlayFS is a modern union filesystem that is similar to AUFS, but faster and with a simpler implementation. Docker provides two storage drivers for OverlayFS: the original overlay , and the newer and more stable overlay2 .

What are overlays in Docker?

The overlay network driver creates a distributed network among multiple Docker daemon hosts. This network sits on top of (overlays) the host-specific networks, allowing containers connected to it (including swarm service containers) to communicate securely when encryption is enabled.

How do I clean up Docker overlay2 folder?

How To Clean Up Docker Overlay2? In order to clean up unused containers and images, we can use the docker system prune. A prune will never remove consists of: Operational containers.

What is var lib Docker overlay?

Overlay in DockerDocker uses the overlay filesystem to create images as well as to position the container layer on top of the image layers. When an image is downloaded, its layers are located inside the /var/lib/docker/overlay2 folder.


1 Answers

This seems to be related to the OVERLAY_FS_REDIRECT_DIR kernel option, which is described in Kconfig as:

config OVERLAY_FS_REDIRECT_DIR
bool "Overlayfs: turn on redirect dir feature by default"
depends on OVERLAY_FS
help

If this config option is enabled then overlay filesystems will use redirects when renaming directories by default. In this case it is still possible to turn off redirects globally with the "redirect_dir=off" module option or on a filesystem instance basis with the "redirect_dir=off" mount option.

Note, that redirects are not backward compatible. That is, mounting an overlay which has redirects on a kernel that doesn't support this feature will have unexpected results.

If unsure, say N.

Some discussion on moby issues 34342 and 34320 indicates that, if all of the following are true:

  1. the OVERLAY_FS_REDIRECT_DIR kernel option is enabled
  2. the storage engine is overlay2 (the default in most cases)
  3. docker is storing images on a file system that is not mounted with redirect_dir=off
  4. the "native" diff driver is used
  5. a nonempty directory is renamed as part of a docker build, e.g. in a Dockerfile like the following:

    FROM busybox
    
    RUN mkdir /dir1
    RUN touch /dir1/newfile
    RUN mv /dir1 /dir2
    

Then the resulting image will not properly record the contents of the renamed directory (i.e., dir2 will not contain newfile) because the directory rename was implemented as a redirect using an extended file attribute (xattr) which is not understood by the docker archiving process. To solve this problem, when the first three conditions above are met, then docker will use the "naive" diff driver which produces correct images, but is slower than the "native" diff driver.

It seems like it is safe to ignore the warning, but if you notice slow builds, then you could try remounting the volume serving /var/lib/docker with the option redirect_dir=off.

like image 178
kbolino Avatar answered Sep 28 '22 05:09

kbolino