简体   繁体   English

如何导出lxc容器?

[英]How do I export a lxc container?

Is it possible to export a lxc container to another machine? 是否可以将lxc容器导出到另一台机器? There are some tools like lxc-snap and lxc-clone will those help in exporting to another system? 有一些工具,例如lxc-snaplxc-clone可以帮助导出到另一个系统吗? Can I copy paste the rootfs folder or is there a standard way of doing this? 我可以复制粘贴rootfs文件夹吗,或者有标准的方法吗?

Edit: I ended chrooting into the /var/lib/lxc/centos folder and getting things done as that was sufficient for my use case. 编辑:我结束了chroot进入/ var / lib / lxc / centos文件夹并完成工作,因为这足以满足我的用例。 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. 但是,请确保根据主机系统体系结构使用chroot,即如果主机是64位计算机,但您的安装是32位,则使用linux32 chroot。

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/ https://insights.ubuntu.com/2016/04/01/lxd-2-0-image-management-512/

the default container location is: /var/lib/lxc/cn_name 默认容器位置为:/ 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. 您可以lxc停止容器,然后使用典型工具(例如scp,rsync等)将cn_name内容复制到新计算机中的相同位置。

You can tar up the entire cn_name directory also then untar on the new machine in the same directory 您可以将整个cn_name目录打包,然后在同一目录的新计算机上解压缩

Just remember whatever you do ... preserver owner etc attributes for files & directories you copy so they are still runnable on the new system. 只要记住您所做的一切即可...复制的文件和目录的目录所有者等属性,以便它们仍可在新系统上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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