2017-05-02 127 views
1

有沒有辦法在Docker中運行LXD?例如。有沒有辦法在Docker中運行LXD?

在使用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守護程序的工作,但我不能因爲與cgroup的錯誤開始LXD容器。

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 
+0

不可否認 - 我沒有線索,所以我在寫評論。我只是想知道,如果你使用LXD,你甚至會使用Docker嗎?您應該反轉邏輯並在LXC內部運行Docker。 – Mjh

+0

是的,我可以在沒有問題的情況下在LXD或LXC中運行Docker。這是一個常見的任務。但想象一下,您擁有一個輕量級操作系統和Docker的少數節點集羣。通過Docker運行應用程序或分佈式文件系統(例如GlusterFS)很容易,即使您可以運行KVM虛擬機作爲Docker容器。一切都將與Docker Swarm一起工作。所以問題是:有沒有辦法在Docker中運行LXD?也許它沒有用,但恕我直言,它應該工作。 –

+0

這看起來倒退了。 LXD是一個完整的Linux環境,Docker受到了極大的限制。我期待的問題是「我可以在LXD中運行Docker」,但不是「我可以在Docker中運行LXD」。問這個問題讓我問,你想做什麼?爲什麼? – JamieB

回答

1

LXD/LXC提供一個全棧的Linux環境。 Docker是一個引擎,允許你打包應用程序和依賴項。

Docker提供了一個受限的環境,故意禁用某些與網絡和存儲持久性相關的操作系統功能。

您可以在LXD/LXC容器中運行Docker(事實上,Docker曾經使用LXC作爲其底層技術 - 可能仍然會這樣做),但是您不會在Docker容器中運行LXC容器。

相關問題