Docker Community Forums

Share and learn in the Docker community.

Best way to change the Docker data directory on Ubuntu Server 18.04

I would like to change the docker data directory on Ubuntu Server 18.04. I am using Alibaba Cloud and have added a data disk of 100 GB which I mounted on /data.

So, instead of /var/lib/docker, I want Docker to use /data/docker.
I am using the latest stable version of docker.

There are many tutorials on the Internet that give different ways of doing it, but I am not sure of the right one… Please help me.

I am also doing the Docker Mastery course on Udemy, where I asked the same question, but no one replied.

Server: Docker Engine - Community
Version:          18.09.3
API version:      1.39 (minimum version 1.12)

No one knows the best way? :frowning:

Don’t know if this is the best way, I would copy the existing files to the new disk and then mount it into /var/lib/docker.

1 Like

yea, copy the data to the new directory, and then in your:
/etc/docker/daemon.json file.

If the file dosnt exist, then it should look like:
{ “data-root”: “/data/docker” }

else if you allready have the file, add the “data-root” part to the daemon.json file.