mirror of
https://github.com/moby/moby.git
synced 2026-06-24 16:58:54 +00:00
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
This patch updates the function to skip directories that neither contain
a `_data` directory, not have a `opts.json` file.
[daemon/volume/local.New]: 6c5233e109/daemon/volume/local/local.go (L51-L85)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>