How to specify different root directory for Docker on Linux

how can I configure docker so it uses another folder?

EDIT: the thing is that my root / partition is getting fulled and so image processing halts.
I whish instead of using my root partition, docker could store the files inside my /home partition but I don’t know how to do that. thanks!

1 Like

this might be it:

1 Like

tried both solutions (Im in Endeavour OS, based on Arch) and none worked

1 Like

Basically, after stopping docker.service and docker.socket,
I added the the -g parameter to the ExecStart parameter at
ExecStart=/usr/bin/dockerd -g /home/josei/docker -H fd://
I then copied contents
sudo rsync -aqxP /var/lib/docker/ /home/josei/docker

  "data-root": "/mnt/docker"

But it keeps filling up my root partition…
(and so webODM hangs)

EDIT: Wait, I think I got the solution… ill be right back
EDIT2: Seems I was so stupid to enter a wrong location (/mnt/docker), which was still in my root partition

Anyway, the /home/josei/docker , ex /var/lib/docker folder is inaccessible, I can’t enter it through terminal nor through GUI file manager… how can I know what it holds and what size it is occupying?

1 Like

this is not the correct solution. This is the solution:

Images location

By default, docker images are located at /var/lib/docker. They can be moved to other partitions, e.g. if you wish to use a dedicated partition or disk for your images. In this example, we will move the images to /mnt/docker.

First, stop docker.service, which will also stop all currently running containers and unmount any running images. You may then move the images from /var/lib/docker to the target destination, e.g. cp -r /var/lib/docker /mnt/docker.

Configure data-root in /etc/docker/daemon.json:


{ “data-root”: “/mnt/docker” }

Restart docker.service to apply changes.


I have had a simiar experience when I had only 160gb os drive to work with. I successfully moved docker as well as odm storage for finished projects however I found that during processing intermediate files get stored in the home directory other than the docker directory. I cant remember the exact location. Since thwn I have upgraded my os directory to 1tb ssd.

Also keep in mind that selecting optimize disk space helps in removing the intermediate files during processing.

Hope this helps.