How to easily share containers between multiple PCs using external disk?

Hi,

I’m a SW developer and I work from multiple physical locations (office, home, secondary home), so I have been taking my labtop with me when going back and forth. I wish to transition to desktop PCs and just move an external SSD disk with all my data.

I wish to put my development environment in one or more LXD container(s), which I can keep on the external disk.
Which would be the simplest way to share these containers between multiple PCs?

So far the best I have come up with is to run the containers independently on each host PC (i.e. backend storage on the host PC) and then export the container image to the external disk at the end of the work day. Move location and then import the image on the next PC and make a new container from the imported image. But this is quite cumbersome and I could easily forget to export before leaving the location. I wouldn’t mind having a script that does the export / import on power down / up, but I was wondering if there isn’t a better way.

Could I create a filesystem on the external disk for one backend storage shared by all LXD instances (one for each host PC)?

A virtual machine would do the trick, but that would come with a performance penalty, so that is not an option.

PS: one location has an unreliable and low speed internet connection, so I need to be able to bring all my data. I also need to be able to start work from a new location without initial internet connection (this is important).

Assuming you’re using the LXD snap, you could in theory put /var/snap/lxd on external storage, bind-mounting that external storage onto it. Then when moving to another system, you’ll need to snap stop lxd and snap disable lxd to avoid issues on the source computer, unmount /var/snap/lxd, unplug the disk, plug it on the other computer, mount /var/snap/lxd from the external media, then snap enable lxd and snap start lxd.

This should be fine though you’ll also have to make sure that the LXD version on both systems is the same (more specifically, making sure not to re-attach the storage on a system with an older version).

It looks suitable for the init system of the distribution to perform this task on every boot/shutdown.

Yes, I’m on Ubuntu and using snap.

Would I just invite trouble if I tried to make an LXD dedicated ZFS partition on the external disk for storage backend?

A different soln:
quite some time ago (start of covid), I had this issue. Bought a 2 TB ssd and a installed(dd my entire disk). Since we a complete dell shop, it was easy to swap by purchasing a DVD-ROM-HDD caddy. Looks weird but works.

IIRC, even eSATA works great for ZFS (that I use for backup - zfs send)

In your case, the whole operating resides on a removable disk. You are connecting it with SATA or eSATA, so it should be fine in terms of performance. Your only concern would be for the desktop environment to be able to boot up properly considering the different GPUs.