On my server I have 2 SSD. One is system SSD and another one I want to spare for running containers. I expect 1000 containers launched on my app and even more. But I do not want to change docker root directory with all that overlay2 and the rest. Only when new container starts, the container disk should be on second SSD.
Can I achieve it with links? Can I create a link for /var/lib/docker/containers to another disk mounted in the system? Will that work?
some config files like the hosts file or the resolv conf
logs as json files when using the default json log driver
not the writable filesystem. That is still in the overlay2 folder or any folder that belongs to the storage driver. Since the container filesystem should not even be written heavily in most cases, you could bind mount folders from a separate disk. There would be only temporary files on the container filesystem like pid files. There are environments where the container filesystem is not even writable so it is better to avoid that
The experimental âdocker checkpointâ feature also uses the containers folder as default target directory, but that can be changed.
If for any reason you still want to handle the containers folder on a separate disk:
I never tried links, but you could only use symbolic links and I would try not to do that usually as I never know what it will break later even if it works now. You can still test if you have a test environment, but.you could also bind mount a folder from one disk to another or create a new partition and mount that.
Like @rimelek already wrote, the container folder is not the one holding the container filesystem, it is the overerlay2 folder.
If you prevent the container from writing into the container filesystem, there would be no need to tinker with anything inside the docker data-root folder. A container filesystem consists of (read only) image layers from the image, and a write layer.
You can use docker diff <container id or name>to detect if and where data is written into the container filesystem. If you map volumes (or bind) to container folders, persistent data will be written outside the container filesystem.