我可以从自己的自定义操作系统创建LXC映像吗? [英] can i create a LXC image from my own custom OS?

查看:408
本文介绍了我可以从自己的自定义操作系统创建LXC映像吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是lxc的新手.我想从现有的操作系​​统(我自己的以不同体系结构编译的unix内核)中创建自己的lxc容器.我正在尝试使用"lxc-create".谁能建议我如何创建自己的容器,是否可以用这种方法创建一个容器?创建自己的容器后,是否需要更改任何配置?

Am new to lxc. I want to create my own lxc containers from existing OSs(my own unix kernel compiled in different architecture). I am trying to use "lxc-create". Can anyone suggest me how to create my own containers and is it possible to create one or not with this approach? Do I need to change any configurations after creating my own container?

如果lxc不适合此功能,我可以使用其他任何容器引擎来实现吗? P.S.我不需要虚拟机或任何虚拟机管理程序即可实现相同的目的.

If lxc is not suitable for this, can I achieve it with any other container-engines? P.S. I don't need vms or any hypervisors to achieve the same.

推荐答案

仅说明一下,您是否要从自己运行的操作系统为容器创建映像?如果是这样,我认为使用lxc-create是不可能的.

Just to clarify, are you trying to create the image for the container from your own running operating system? If so, I don't believe this is possible using lxc-create.

lxc-create可用于下载各种发行版的公共可用图像.例如,您可以运行以下命令:

lxc-create can be used to download publicly available images of various distributions. For example, you can run this command:

 lxc-create -t download -n my-container-name 

下载图像并从该图像创建容器.当您运行此命令时,下载模板将显示可用发行版列表,您将可以从中创建运行的conainter.有关此的更多信息,请参见此处.

to download an image and create a container from that image. When you run this command, a download template will display a list of distributions available, from which you will be able to create a running conainter. For more information on this please see here.

将您自己的容器配置为自己的规范的通常过程是从基本操作系统映像中构建满足您要求的映像.您可以通过两种方法来执行此操作.在手动构建图像"部分的此处:

The usual procedure to configure you own containers to your own specifications would be to build an image for your requirements from a base operating system image. There are a couple of ways you can do this. From the 'Manually building an image section' section here:

1)生成容器文件系统.这完全取决于您使用的发行版.对于Ubuntu和Debian,可以使用debootstrap.

1) Generate a container filesystem. This entirely depends on the distribution you’re using. For Ubuntu and Debian, it would be by using debootstrap.

2)配置在容器中正常运行分发所需的任何内容(如果需要).

2) Configure anything that’s needed for the distribution to work properly in a container (if anything is needed).

3)创建该容器文件系统的压缩文件,可以选择对其进行压缩.

3) Make a tarball of that container filesystem, optionally compress it.

4)根据上述内容编写一个新的metadata.yaml文件.

4) Write a new metadata.yaml file based on the one described above.

5)创建另一个包含该metadata.yaml文件的tarball.

5) Create another tarball containing that metadata.yaml file.

6)使用以下命令将这两个压缩文件导入为LXD图像:

6) Import those two tarballs as a LXD image with:

lxc image import <metadata tarball> <rootfs tarball> --alias some-name

另一种方法是从通用linux映像创建运行中的容器(如先前使用lxc-create命令所述),然后输入容器的外壳,以便您可以根据需要更改配置,然后发布修改后的容器作为新图像.例如:

Another method would be to create a running container from a generic linux image (as described earlier using the lxc-create command), then enter the shell of the container so that you can change the configuration to you required needs, then publish the amended container as a new image. For example:

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

一旦配置了目标图像,便可以从这些图像运行容器.

Once you have configured your purpose made images, you can run containers from those images.

关于您关于其他可能性的问题,我建议您研究Docker容器.如果您以某种能力使用Google Container Engine(如本文中的标记所建议),则可以利用Container Registry标记和存储图像的不同版本,并且还有大量的文档和公共资料.可供Docker在线使用的映像如果您想将其与GCP中的VM集成,请在此处如果您想了解更多.

In relation to your question about other possibilities, I would suggest looking into Docker containers. If you are using Google Container Engine in some capacity (as the tags on this post suggest) you would then be able to utilise Container Registry to tag and store the different version of your images, and there is also a great deal of documentation and public images available for Docker online. If you would like to integrate it with VMs in GCP, there is some good information here if you would like to learn more.

这篇关于我可以从自己的自定义操作系统创建LXC映像吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆