I just did some tests and found that to get an accurate count of disk usage for /var/lib/docker, you need to pass the -x option to du so it doesn’t count files in mounted overlay file systems.
Stopping docker, which unmounts the overlay filesystems will also work but of course is less convenient then just using the -x option for du.
At least this is the case when using the overlay2 docker backend, I would assume it’s the same for most of the docker backends.
Edit: Strangely the sizes reported by running ‘docker images’ shows image ‘local_discourse/app’ with a size of 2.82GB and image ‘discourse/base’ with a size of 1.73GB.
Which would mean the images take 4.55 GB but running ‘du -sh /var/lib/docker’ shows 3.1GB total.
I’m not sure why there is a difference in size or why there are two images for discourse.
Maybe the images share files and the ‘docker images’ command doesn’t account for that.