How to do [live] migration of container to the different node?

How to do (optionally live) migration of container to the different node?

The case - multiple Ubuntu 18.04/20.04 LTS servers, latest LXD from snap, routed network with public IPs on all containers. I need to migrate container from one server to another with a minimal downtime or (via CRIU) with no downtime and saving all states including network if it’s possible.

vzmigrate from OpenVZ has this algorithms:

  1. copy/sync files while container is running
  2. stop (or suspend) container
  3. sync changed delta files (and RAM, kernel and network state via CRIU in case of “live” migration)
  4. run/resume container
  5. container is running on the new node (all network connections are not broken if CRIU was used)
  6. optional removing files from old node in background

Is it possible to have similar scenario with LXD?

You can install & enable CRIU. But it is not as good as OpenVZ (sorry). CRIU is also owned by Virtuozzo.

More information:

To enable CRIU:

Thanks for this link, I did not know about this options, but what about all other steps?

I was able to find lxd copy/move command with option target, but official documentation looks not enough… Can I do not delete files from unsuccessful/aborted transfers? Will network state be transferred like memory and running processes? How to achieve small downtime without CRIU (something like “copy while running, stop CT, copy delta”) ?

You can delete containers after (failed) transfers. This depends on whether it is at the end or the beginning of the migration. But you can easily find out for yourself. I never had any problems with not being able to delete containers via lxd commands

You can find the commands to move/copy containers here: