Intuitively, when I export a container from one computer and import the resulting file into LXD on another computer, I obviously am wanting to import that file into the LXD server as it is setup on the second computer. Or, in other words, the clear intent is to import the container-filename.tar.gz into the second computer on LXD however LXD is setup on that second system.
However, it doesn’t seem to work quite that way.
I ran into an issue tonight where a container on my laptop which I exported, rsynced to a server, then imported on that server resulted in the following error:
user@server:/zfs$ sudo lxc import u22-blank.tar.gz
Importing instance: 100% (575.71MB/s)Error: Storage pool not found: Storage pool not found
Why would the import process not be able to find the storage pool on the LXD server that I was importing into? The storage pool exists and seems to be functioning properly, but the import process cannot seem to find it. To me that doesn’t make sense.
After some searching, I found the --storage option and took a bit of trial and error, as well as looking back at my notes, to figure out what the specific issue was in my case here. The --storage option isn’t even asking for the actual zfs dataset being used for LXD on the second computer, which in this case is serverpool/lxd. Instead, --storage needs the name that was used during ‘lxd init’ for the following part:
Name of the new storage pool [default=default]:
Turns out, on my laptop I left that setting above as the default and on the server I used ‘lxd’ for the name. So, importing with --storage=lxd got the imports working.
But still, shouldn’t the lxc import process be able to determine without user input that the LXD server being imported into was configured with whatever name was used during the “Name of the new storage pool [default=default]:” init part?
Something else I found out is that --storage=name is needed also only when the export is done using the --optimized-storage flag because without using that flag the filename.tar.gz imported just fine without needing --storage=name.
Just seems odd to me.
The way I think of it, metaphorically, is I’m taking something out of a box and putting it into another box. But the process wants to know what I named the second box. And I’m thinking, “Why does it even matter what I named the box? Just go inside the box like I am instructing.”
I’m assuming that had I used the same name for “Name of the new storage pool [default=default]:” on both my laptop and the server that the imports would have worked without needing the extra --storage=name part, but I did not test this so not certain yet.
And I’m guessing there’s probably a good reason why the name part from “Name of the new storage pool [default=default]:” is required to be specified with --storage=name in this situation.
Maybe this is an opportunity for me to learn a bit more about LXD, if anyone feels like explaining why it works this way.