Docker writes to root partition instead of mounted drive despite correct data-root config

Hi,

I’m facing a persistent issue where Docker ignores my physical HDD and writes data to the OS partition instead.

Setup:

  • External Disk: 550GB partition mounted at /mnt/sdb.
  • Config: /etc/docker/daemon.json is set to "data-root": "/mnt/sdb/docker-root".
  • Symptom: docker info confirms the correct Root Dir, but images and containers are physically stored on the OS partition (sda) under the same path string, rather than the mounted disk (sdb1).

The Issue: Even when I manually mount the drive, Docker seems to be “stuck” writing to the underlying mount point folder on the root filesystem. If I unmount the drive, the data is still there on the OS partition.

Troubleshooting done:

  1. Verified data-root path in docker info.
  2. Formatted the disk and updated UUID in fstab.
  3. Tried systemctl stop dockermountstart docker, but it still bypasses the physical disk.

Question: How do I force Docker to recognize the actual mounted storage and stop it from creating/using the “shadow” directory on the OS partition? Do I need to re-initialize the containerd config as well?

This doesn’t make sense. You defined a custom path for the data-root folder - docker is using it. It is not, and can not be aware that it’s a mount point that is mounted after the docker daemon is started. If you start docker in the order you write above, it should start properly.

Fresh Docker v29 started delegating the storage driver to containerd, so that most of the data will be written into /var/lib/containerd. Just setting the data-root is not enough. I would need to lookup how to configure how to configure containerd to point to a different location.

First you need to solve the problem how to delay the docker engine, until the external drive is mounted. It’s not a use-case I encountered in the last 11 years using containers, so I can’t help you with that.

If the problem is the containerd image store that @meyay mentioned, I had to often share this recently:

https://docs.docker.com/engine/daemon/#daemon-data-directory

It shows the data root setting for Docker and Containerd as well.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.