Skip to content

Docker audit fix · Volume Permissions

How to Secure Docker Volume Directory Permissions

Docker creates /var/lib/docker/volumes with mode 701 and sets it back to 701 every time the daemon starts, so no other local account can list the volumes in it. A looser mode such as 755 almost always comes from a recursive chmod; restore it with chmod 701.

Hiren KalariyaHiren KalariyaLast reviewed volume-permissions
CtrlOpsVolume Directory PermissionsMEDIUM

What did your audit say?

WARN · when the audit printed

Anything looser (e.g. 755, 777)

Someone has widened the volumes root since the daemon last started, usually with a recursive chmod that loosened /var/lib/docker as well. Any local account can then list every volume and reach its data, limited only by each volume's own mode.

Severity
Medium
Needs root or sudo
Yes
Results it can return
WARN · SKIP · PASS
Check in this audit
5 of 7

Every threshold on this page is transcribed from the docker-security-volume-permissions audit script that CtrlOps runs, and a build check fails if the two ever disagree. See all 7 Volume Permissions checks, or how the audit runs.

The check reads exactly one value: the octal mode of the /var/lib/docker/volumes directory itself, taken with stat -c '%a' run through as_root. Four modes pass and no others - 700, 701, 710 and 711. 701 is the mode Docker sets, and none of the other three gives other local accounts more than 701 does. Anything else, 755 and 777 included, is a WARN quoting the mode it found, and an empty result from stat is a SKIP rather than a pass. Nothing below the volumes root is examined; the per-volume _data modes belong to the World-Writable Volumes check.

Needs root or sudo and an existing /var/lib/docker/volumes; otherwise SKIP. It looks at exactly one directory - the volumes root itself - and accepts four modes: 700, 701, 710, 711. Anything else, including 755, is a WARN. Per-volume modes are deliberately out of scope here (the World-Writable Volumes check covers them), so the two checks do not report the same misconfiguration twice. The Docker daemon sets this directory back to 701 every time it starts, so a WARN means the mode was changed after the daemon last started, almost always by hand or by a script.

What each result means
ResultWhenWhat it means
SKIPNo root / directory absent / stat failedNothing was verified. The mode was never read, so it could be anything.
PASSStandard Docker modeThe volumes root has Docker's own 701 or one of the three modes that are no looser, so an unprivileged local account cannot list the volumes in it.
WARNAnything looser (e.g. 755, 777)Someone has widened the volumes root since the daemon last started, usually with a recursive chmod that loosened /var/lib/docker as well. Any local account can then list every volume and reach its data, limited only by each volume's own mode.

Docker creates /var/lib/docker with mode 0710 and /var/lib/docker/volumes with 0701, both owned by root. The parent keeps other local accounts out entirely; the volumes root is the second layer, letting a process traverse to a volume whose name it already knows without letting anyone list the volumes. Each volume's _data directory is created 0755, so once both layers are loosened, any local account can read every volume's database files, uploads and secrets. CIS Docker 1.2 host configuration / 3.x file permissions.

  • Operators who ran chmod -R 755 /var/lib/docker to debug, or backup tools that reset modes on restore.
  • The daemon resets the mode to 701 when it starts, so a WARN that disappears after a reboot or a Docker restart was real until then. Find what changed it, or it will come back.
  • Custom data-root → SKIP; adapt the path.
  1. Restore the volumes directory

    701 is the mode Docker itself sets. 700 and 710 also pass, but the daemon sets 701 again at its next start.

    sh
    sudo chmod 701 /var/lib/docker/volumessudo chown root:root /var/lib/docker/volumes

    Restarting Docker (sudo systemctl restart docker) also restores 701, but it stops every container unless live-restore is on, so the chmod is the fix that needs no downtime.

  2. Check the parent directory

    A recursive chmod that loosened the volumes root usually loosened /var/lib/docker too, and that directory is what keeps local accounts out of every volume.

    sh
    sudo stat -c '%a %U:%G' /var/lib/docker# expected: 710 root:root (711 on a host using userns-remap)sudo chmod 710 /var/lib/docker

  3. Find what loosened it

    Search your cron jobs, deploy scripts and configuration management for a recursive chmod against /var/lib/docker, and remove it.

    sh
    sudo grep -rnE 'chmod +-R.*/var/lib/docker' /etc/cron* /etc/ansible /usr/local/bin /opt 2>/dev/null

sh
sudo stat -c '%a %U:%G %n' /var/lib/docker/volumes# expected: 701 (or 700/710/711) root:root# Confirm an unprivileged account cannot list or traverse it:sudo -u nobody ls /var/lib/docker/volumes            # expected: Permission deniedsudo -u nobody ls /var/lib/docker/volumes/<name>/_data   # expected: Permission denied

Debugging

  • There is no unprivileged fallback, and membership of the docker group does not help: it reaches the daemon, not this directory. Run the audit as root or give the audit account sudo.
  • Docker keeps its data somewhere else. docker info --format '{{.DockerRootDir}}' shows where. A custom data-root in daemon.json, a rootless daemon (volumes under ~/.local/share/docker) and userns-remap (volumes under /var/lib/docker/<uid>.<gid>/volumes) all land here. Run the stat above against the real path.
  • The directory exists but stat returned nothing, which usually means a permission or filesystem problem even under sudo. Run the command by hand to see the error.
  • Someone ran a recursive chmod over /var/lib/docker, which is the usual cause. Restore it with sudo chmod 701 /var/lib/docker/volumes. That mode lets a process traverse into a volume path it already knows but not list the directory; 700 is stricter and also accepted. Check /var/lib/docker itself as well, as in the second step above.
  • A configuration-management run or a recursive chmod in a maintenance script. Search your automation for chmod -R against /var/lib/docker. If you set 700 or 710 and now see 701, that is Docker itself: the daemon sets the directory to 701 when it starts, which still passes.
  • This check looks only at the root directory. The per-volume modes are the World-Writable Volumes check, and neither examines the files inside a volume.

Sources

Next

Re-run the Volume Permissions audit after applying the fix and confirm this check moves to PASS. CtrlOps runs all 7 checks over your existing SSH connection and scores the result, so the change is visible without reading another config file.

Download for MacDownload for WindowsAll 7 Volume Permissions fixes

14-day free trial, no credit card required.

Explore article with AI tools

Written by

Hiren Kalariya

Co-Founder & CEO, TST Technology

Hiren Kalariya is the Co-Founder and CEO of TST Technology and the product lead behind CtrlOps, a local-first desktop app that makes Linux server management fast and easy for developers and DevOps teams. Over the past five years he has shipped 60+ production systems, and he still tests every tool he writes about on real servers.

Stop juggling tools. Start managing fleets.

PuTTY
Termius
MobaXterm
WinSCP
SecureCRT
Royal TS
Warp
CtrlOps14 tools left
Webmin
aaPanel
RunCloud
Dokploy
IP spreadsheet
bash (2)
sticky notes

One app. All your servers. No context switching. Free to start, free to leave.

Start instantly · No credit card · Cancel anytime

Your privacy preferences. We use product analytics to improve CtrlOps. Google Analytics cookies and live chat stay off until you allow them. Cookie policy