Thanks to visit codestin.com
Credit goes to github.com

Skip to content

daemon/volume: don't print warnings for non-volume directories#52018

Merged
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:volumes_notfound
Feb 9, 2026
Merged

daemon/volume: don't print warnings for non-volume directories#52018
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:volumes_notfound

Conversation

@thaJeztah
Copy link
Member

daemon/volume: don't print warnings for non-volume directories

When restoring volumes at startup, the local volume driver's constructor (daemon/volume/local.New) iterates over all directories found inside the volume storage path (/var/lib/docker/volumes). It does not (currently) check for presence of other indicators that the directory is an actual volume, such as the _data directory being present, or a opts.json.

In situations where /var/lib/docker/volumes contains directories that were not created by docker, this can result in errors when calculating the size of volumes (docker system df);

Before (re)starting the daemon, create some directories;

mkdir /var/lib/docker/volumes/notavolume
echo "some file" > /var/lib/docker/volumes/notavolume/some-file
mkdir /var/lib/docker/volumes/notavolume2

Then, start the daemon, and run docker system df. The daemon logs will now contain warnings about the path not being found:

WARN[2026-02-09T11:27:31.940713593Z] Failed to determine size of volume            error="lstat /var/lib/docker/volumes/notavolume/_data: no such file or directory" volume=notavolume
WARN[2026-02-09T11:27:31.940765468Z] Failed to determine size of volume            error="lstat /var/lib/docker/volumes/notavolume2/_data: no such file or directory" volume=notavolume2

The calcSize function used to calculate the size of a volume already ignores files within the volume's storage that are not / no longer found, but does not ignore errors if the base directory (_data) itself doesn't exist.

This patch:

  • makes the logs ignore "not found" errors
  • adds a TODO to look into ignoring these directories during daemon startup (when instantiating the driver and restoring volumes).

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

Prevent logging "not found" warnings when calculating volume sizes.

- A picture of a cute animal (not mandatory but encouraged)

When restoring volumes at startup, the local volume driver's constructor
([daemon/volume/local.New]) iterates over all directories found inside the
volume storage path (`/var/lib/docker/volumes`). It does not (currently) check
for presence of other indicators that the directory is an actual volume, such
as the `_data` directory being present, or a `opts.json`.

In situations where `/var/lib/docker/volumes` contains directories that were
not created by docker, this can result in errors when calculating the size
of volumes (`docker system df`);

Before (re)starting the daemon, create some directories;

    mkdir /var/lib/docker/volumes/notavolume
    echo "some file" > /var/lib/docker/volumes/notavolume/some-file
    mkdir /var/lib/docker/volumes/notavolume2

Then, start the daemon, and run `docker system df`. The daemon logs will
now contain warnings about the path not being found:

    WARN[2026-02-09T11:27:31.940713593Z] Failed to determine size of volume            error="lstat /var/lib/docker/volumes/notavolume/_data: no such file or directory" volume=notavolume
    WARN[2026-02-09T11:27:31.940765468Z] Failed to determine size of volume            error="lstat /var/lib/docker/volumes/notavolume2/_data: no such file or directory" volume=notavolume2

The [calcSize] function used to calculate the size of a volume already ignores
files _within_ the volume's storage that are not / no longer found, but does
not ignore errors if the base directory (`_data`) itself doesn't exist.

This patch:

- makes the logs ignore "not found" errors
- adds a TODO to look into ignoring these directories during daemon startup
  (when instantiating the driver and restoring volumes).

[daemon/volume/local.New]: https://github.com/moby/moby/blob/6c5233e1098dc689b2e665087780695ac8864e95/daemon/volume/local/local.go#L51-L85
[calcSize]: https://github.com/moby/moby/blob/daeaac0d3cf147cc7450a3ab9a869327c71bad45/daemon/internal/directory/directory_unix.go#L13-L24

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah merged commit 8abd12c into moby:master Feb 9, 2026
294 of 296 checks passed
@thaJeztah thaJeztah deleted the volumes_notfound branch February 9, 2026 20:06
@vvoland vvoland modified the milestones: 29.2.2, 29.3.0 Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Docker flooding logs when volumes folder is a file-system with lost+found folder

3 participants