daemon/volume: don't print warnings for non-volume directories#52018
Merged
thaJeztah merged 1 commit intomoby:masterfrom Feb 9, 2026
Merged
daemon/volume: don't print warnings for non-volume directories#52018thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah merged 1 commit intomoby:masterfrom
Conversation
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]>
robmry
approved these changes
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_datadirectory being present, or aopts.json.In situations where
/var/lib/docker/volumescontains 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;
Then, start the daemon, and run
docker system df. The daemon logs will now contain warnings about the path not being found: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:
- What I did
- How I did it
- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)