<p>Symlink is an universal solution which works, I've successfully used it plenty of times. I do not recommend using the path you suggested, though, since the files should be owned by either the <code>root</code> or <code>docker</code> users, depending on your distro/OS. Therefore, if you want to use the <code>/home</code> partition, then:</p>
<ul>
<li>shut down docker</li>
<li><code>mv /var/lib/docker /home/</code></li>
<li><code>ln -s /home/docker /var/lib/docker</code></li>
<li>start docker</li>
</ul>
<p>This will usually persist through upgrades unless you uninstall and reinstall Docker.</p>
<p>Now, more recent versions of Docker support an option in <code>/etc/docker/daemon.json</code>, namely the <code>data-root</code> option. So just edit the file and add</p>
<pre><code>{
  &quot;data-root&quot;: &quot;/home/docker&quot;
}
</code></pre>
<p>You can find the whole schema for the file in the <a href="https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file" rel="nofollow noreferrer">docs</a>.</p>

CC BY-SA 4.0
2021-08-06T12:32:49.747Z
2021-08-06T12:32:49.747Z
Claudiu
<p>All my docker related folders are saved in /var/lib/docker. But my / space is very limited. Hence, I would like all of the content present inside this location to go to say /home/User/my_space. How would I do that? I could use symbolic link. But, that will only move the current contents of the location. I would like to move the future changes of the docker also. Please help me :)</p>

<docker><volume>
How would I change the docker's base directory
Diwakar
# How would I change the docker's base directory

(Asked by: username_0 on 2021-08-06)

All my docker related folders are saved in /var/lib/docker. But my / space is very limited. Hence, I would like all of the content present inside this location to go to say /home/User/my\_space. How would I do that? I could use symbolic link. But, that will only move the current contents of the location. I would like to move the future changes of the docker also. Please help me :)

**Tags:** docker, volume


---

## 1 answers

### Answer by username_1 on 2021-08-06. Score: 1

Symlink is an universal solution which works, I've successfully used it plenty of times. I do not recommend using the path you suggested, though, since the files should be owned by either the root or docker users, depending on your distro/OS. Therefore, if you want to use the /home partition, then:

shut down docker
mv /var/lib/docker /home/
ln -s /home/docker /var/lib/docker
start docker

This will usually persist through upgrades unless you uninstall and reinstall Docker.
Now, more recent versions of Docker support an option in /etc/docker/daemon.json, namely the data-root option. So just edit the file and add
{
  "data-root": "/home/docker"
}

You can find the whole schema for the file in the docs.


---

