有没有办法在Docker中运行LXD? [英] Is there a way how to run LXD inside Docker?

查看:281
本文介绍了有没有办法在Docker中运行LXD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在Docker内部运行LXD?例如。

Is there a way how to run LXD inside Docker? eg.

在具有Ubuntu 16.04的主机上:

On the host with ubuntu 16.04:

docker run --rm -it --net host --privileged ubuntu bash

在容器中:

apt update && apt install -y lxd iproute2 btrfs-tools screen bash-completion curl wget apt-transport-https lxcfs lxd-tools lxd-client vim overlayroot libkmod2 libkmod-dev cgroup-tools cgroupfs-mount cgroup-bin

screen -S lxd
# in screen
lxd --debug --group lxd


lxd init
lxc list
lxc launch ubuntu:16.04 test

LXD守护程序可以工作,但由于cgroups错误而无法启动LXD容器。 / p>

LXD daemon works but I can't start LXD container due to errors with cgroups.

error: Error calling 'lxd forkstart test /var/lib/lxd/containers /var/log/lxd/test/lxc.conf': err='exit status 1'
  lxc 20170502151757.409 ERROR lxc_apparmor - lsm/apparmor.c:apparmor_process_label_set:220 - If you really want to start this container, set
  lxc 20170502151757.409 ERROR lxc_apparmor - lsm/apparmor.c:apparmor_process_label_set:221 - lxc.aa_allow_incomplete = 1
  lxc 20170502151757.409 ERROR lxc_apparmor - lsm/apparmor.c:apparmor_process_label_set:222 - in your container configuration file
  lxc 20170502151757.409 ERROR lxc_sync - sync.c:__sync_wait:57 - An error occurred in another process (expected sequence number 5)
  lxc 20170502151757.409 ERROR lxc_start - start.c:__lxc_start:1346 - Failed to spawn container "test".
  lxc 20170502151757.954 ERROR lxc_conf - conf.c:run_buffer:405 - Script exited with status 1.
  lxc 20170502151757.954 ERROR lxc_start - start.c:lxc_fini:546 - Failed to run lxc.hook.post-stop for container "test".

我也尝试过:

--cap-add=ALL
--volume /dev:/dev
--pid=host
--volume /sys/fs/cgroup:/sys/fs/cgroup


推荐答案

可以运行lxc在docker内部,因此也应该可以运行lxd。该错误表明您需要添加行

It is possible to run lxc inside docker, so it should also be possible to run lxd. The error indicates that you need to add the line

lxc.aa_allow_incomplete = 1

到您的容器配置。

我做了一个概念验证,展示了一个lxc容器如何可以在docker容器中轻松运行: https://github.com/micw/docker-lxc -demo

I did a proof of concept that shows how an lxc container can easily be run within a docker container: https://github.com/micw/docker-lxc-demo

这篇关于有没有办法在Docker中运行LXD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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