def run(memory, memory_swap, cpu_shares, user, image_name, image_dir,
container_dir, command):
container_id = str(uuid.uuid4())
# linux.clone(callback, flags, callback_args) is modeled after the Glibc
# version. see: "man 2 clone"
flags = (linux.CLONE_NEWPID | linux.CLONE_NEWNS | linux.CLONE_NEWUTS |
linux.CLONE_NEWNET)
callback_args = (command, image_name, image_dir, container_id,
container_dir, cpu_shares, memory, memory_swap, user)
pid = linux.clone(contain, flags, callback_args)
# This is the parent, pid contains the PID of the forked process
# Wait for the forked child, fetch the exit status
_, status = os.waitpid(pid, 0)
print('{} exited with status {}'.format(pid, status))
评论列表
文章目录