跳转到主要内容

lxc4u

项目描述

警告!这仍是一个正在进行中的工作。

为在Ubuntu 12.04和Ubuntu 12.04容器中管理LXC提供工具。其他容器不支持(目前?)

  • 使用overlayfs创建容器

  • 可以处理多个overlayfs层

工作示例

创建名为 test1 的容器

import lxc4u

test1_lxc = lxc4u.create('test1')
# Wait a long time...

# Start the container
test1_lxc.start()

创建覆盖 test1 的容器

import lxc4u

test1_overlay_lxc = lxc4u.create('test1_overlay', base='test1',
                                overlays=['overlay_path'])

# Start the container
test1_overlay_lxc.start()

test1_overlay_lxc.destroy()

创建具有多个覆盖 test1 的容器。最右边的覆盖是最高覆盖目录

import lxc4u

test1_overlay_lxc = lxc4u.create('test1_overlay', base='test1',
                            overlays=['overlay1_path', 'overlay2_path'])

# Start the container
test1_overlay_lxc.start()

这些示例尚未实现。很快!

启动名为 test1 的容器。这假设您的系统中已正确配置了lxc

import lxc4u

# Start container
test1_lxc = lxc4u.start('test1')

# Stop container
test1_lxc.stop()
# or lxc4u.stop('test1')

可能的接口示例

使用test1作为基础启动临时容器

import lxc4u

# Start container
test1_ephemeral_lxc = lxc4u.start('test1', ephemeral=True)

# Stop container
test1_ephemeral_lxc.stop()

使用具有静态网络设置的test1启动临时容器

import lxc4u

network_settings = dict(
    ip="10.0.3.5",
    gateway="10.0.3.1",
    netmask="255.255.255.0",
    network="10.0.3.0",
)

# Start container
test1_ephemeral_lxc = lxc4u.start('test1', ephemeral=True,
                                static_network=network_settings)

# Stop container
test1_ephemeral_lxc.stop()

使用启动命令(必须在容器的路径上可用)启动临时容器

import lxc4u

# Start container
test1_ephemeral_lxc = lxc4u.start('test1', ephemeral=True,
                    startup_command="/usr/local/bin/somecommand")

# Stop container
test1_ephemeral_lxc.stop()

项目详情


下载文件

下载适合您平台文件的文件。如果您不确定要选择哪个,请了解更多关于 安装包 的信息。

源分发

lxc4u-0.0.4.tar.gz (6.9 kB 查看哈希值)

上传时间

支持