'Change default volume mount point for docker rootless?

I saw this post with different solutions for standard docker installation: How to change the default location for "docker create volume" command?

At first glance I struggle to repeat the steps to change the default mount point for the rootless installation. Should it be the same? What would be the procedure?



Solution 1:[1]

We ended up with the indirect solution. We have identified the directory where the volumes are mounted by default and created a symbolic link which points to the place where we actually want to store the data. In our case it was enough. Something like that:

sudo ln -s /data /home/ubuntu/.local/share/docker/volumes"

Solution 2:[2]

I just got it working. I had some issues because I had the service running while trying to change configurations. Key takeaways:

  1. The config file is indeed stored in ~/.config/docker/. One must make a daemon.json file here in order to change preferences. We would like to change the data-root option (and storage-driver, in case the drive does not have capabilities

  2. To start and stop the headless service one runs systemctl --user [start | stop] docker.

    a. Running the systemwide service starts a parallel and separate instance of docker, which is not rootless.

    b. When stopping make sure to stop the docker.socketfirst.

Sources are (see Useage section for rootless) and (config file information)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fedor Petrov
Solution 2