12. Migrating Containers

Take note of the following:

  • The source container must be stopped.
  • The name and UUID of the migrated container must be unique on the destination node.
  • The migrated container keeps the source’s UUID.
  • The MAC address of the migrated container must be unique within the destination node’s network. In this demo, all nodes belong to the same network, so MAC addresses must be unique across all nodes.
  • The data on container’s drive C: will be lost after migration. The data on persistent volumes will remain.

Migrate a container and delete the source:

$ virsh --connect docker://node3.winctpreview.com migrate vpnclient<N>_winct03nano --desturi docker://node1.winctpreview.com --offline --persistent --undefinesource

Migrate a container under a new name and delete the source:

$ virsh --connect docker://node3.winctpreview.com migrate vpnclient<N>_winct03nano --desturi docker://node1.winctpreview.com --dname vpnclient<N>_winct03nano_migrated --offline --persistent --undefinesource

Migrate a container under a new name and keep the source:

$ virsh --connect docker://node3.winctpreview.com migrate vpnclient<N>_winct03nano --desturi docker://node1.winctpreview.com --dname vpnclient<N>_winct03nano_migrated --offline --persistent

Note

In the latter case, the container can only be migrated once. On the second attempt, the UUIDs of the source container and the one migrated earlier will be the same, which will cause a conflict. You can, however, create a container with a new UUID from the source’s configuration file and migrate it.