Ok, there is a post about changing the location of the Docker data, but what if I need to place the containers' filesystem on one drive (SSD) but keep images on another (HDD)?
Is there a way to do this in WSL2?
Ok, there is a post about changing the location of the Docker data, but what if I need to place the containers' filesystem on one drive (SSD) but keep images on another (HDD)?
Is there a way to do this in WSL2?
In the purest form of your question, I think I'd go with, "No." As mentioned in the documentation:
Warning: Do not directly manipulate any files or directories within
/var/lib/docker/. These files and directories are managed by Docker.
And while Docker Desktop with WSL2 doesn't place the files in this directory, the concept would still hold true.
However, I think the way your question is phrased might be a bit ambiguous. It all depends on what you mean by "container filesystem". We could look at that two ways:
The overlay2 filesystem that Docker uses (at least by default 1) to provide the container layer stores the layers in the same location as those for the images. As far as I can tell from the Storage Driver documentation, there is no way to choose a different driver for containers vs. images.
1 Docker Desktop currently provides a Beta option to use Containerd for pulling images. On my system, with this in place, the storage driver is stargz.
But you can also mount storage as Docker Volumes into your containers, of course. By doing this, you can specify a location for that Volume that is on the WSL2 distribution's filesystem that you are using.
Since you've already moved your docker-desktop-data to another drive, I assume that means that your distribution is already on the "original" drive. Regardless, see my answer here for updated instructions on how to move distributions. The Blog you referenced is a bit out of date -- It will work, but there are easier ways at this point.