简体   繁体   English

从本地 centos 模板 (tar.gz) 创建一个 LXC 容器

[英]Create an LXC container from a local centos template (tar.gz)

I have a custom centos, where we made some changes, and I would like to create a LXC from that template.我有一个自定义的 centos,我们在其中进行了一些更改,我想从该模板创建一个 LXC。 Is it possible ?是否有可能 ?

Possible?可能吗? Yes.是的。 depending on the custom centos and if you need to run it privileged or not, it can get really complicated.取决于自定义的 centos,如果您需要以特权方式运行它,它会变得非常复杂。 The basics are easy though.虽然基础很容易。

For lxc v1 , you just need to create config file for container in /var/lib/lxc or whatever your lxc path is and untar the rootfs somewhere lxc can access, set its path in config and try to run it.对于 lxc v1 ,您只需要在 /var/lib/lxc 或任何 lxc 路径中为容器创建配置文件,然后解压缩 lxc 可以访问的某个地方的 rootfs,在配置中设置其路径并尝试运行它。

It would be best if you first make a normal centos container, look where it has config,rootfs , what file permissions it has, network config and so on.最好先制作一个普通的 centos 容器,看看它在哪里有 config,rootfs ,它有什么文件权限,网络配置等等。 Then you just try to mirror its config for your own image.然后您只需尝试为您自己的图像镜像其配置。

if it doesn't start right away , try starting in foreground (-F ) and/or look in logfile .如果它没有立即启动,请尝试从前台 (-F) 启动和/或查看 logfile 。

For lxd it is mostly the same, but you need to create the image and put it in your local repository.对于 lxd,它大致相同,但您需要创建映像并将其放入本地存储库。 It is mostly covered in https://osso.nl/blog/lxc-create-image-debian-squeeze/它主要涵盖在https://osso.nl/blog/lxc-create-image-debian-squeeze/

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

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