简体   繁体   中英

How do I export a lxc container?

Is it possible to export a lxc container to another machine? There are some tools like lxc-snap and lxc-clone will those help in exporting to another system? Can I copy paste the rootfs folder or is there a standard way of doing this?

Edit: I ended chrooting into the /var/lib/lxc/centos folder and getting things done as that was sufficient for my use case. However make sure that you chroot according to the host system architecture ie use linux32 chroot if the host is a 64 bit machine but your installation is 32 bit.

Did you try:

Turning a container into an image

The easiest way by far to build an image with LXD is to just turn a container into an image.

This can be done with:

lxc launch ubuntu:14.04 my-container
lxc exec my-container bash
<do whatever change you want>
lxc publish my-container --alias my-new-image
You can even turn a past container snapshot into a new image:

lxc publish my-container/some-snapshot --alias some-image

From https://insights.ubuntu.com/2016/04/01/lxd-2-0-image-management-512/

the default container location is: /var/lib/lxc/cn_name

You can lxc-stop the container then copy the cn_name contents to the same location in the new machine using typical tools such as scp, rsync etc.

You can tar up the entire cn_name directory also then untar on the new machine in the same directory

Just remember whatever you do ... preserver owner etc attributes for files & directories you copy so they are still runnable on the new system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM