I'm trying to install and run docker inside a LXC container (through LXD).

The container is created using lxc launch ubuntu:16.04 democontainer, and after I login and install docker (v1.12.3) it always fails in starting docker with the error:

FATA[0001] Error starting daemon: Devices cgroup isn't mounted

I have already tried to add this to the file /var/lib/lxc/democontainer/config

lxc.aa_profile = unconfined
lxc.cap.drop =

(and also lxc.mount.auto = cgroup) as stated here, but the result is the same. What may be the problem?

The host system is a Ubuntu 14.04.5 (kernel 4.2.0-42-generic) and the container an Ubuntu 16.04.1. Docker works fine in the host system (v 1.13.0)

  • Can I ask what's your use case? Docker and LXC are both providing containerization. Moreover, they're doing it the same way using kernel namespacing. So, effectively, you're asking for a way to have containers nested. That's a bit odd, unless you have a really good reason to do so. Could you elaborate a bit more on why you want to do this? Because, yeah, by default a container restricts the capabilities in a way that you cannot create new (sub-)namespaces. – gertvdijk Jan 31 '17 at 13:00
  • Yes, I know it is a little far fetched. I as basically trying to create a docker cluster, but using containers instead of vm's. – Salem Jan 31 '17 at 14:17
  • 2
    Try this – George Udosen Jan 31 '17 at 15:21

This works on 16.04 now. See the following q/a for more details:

What is the workaround for LXD-nested pivileged docker (/dev/.lxc/proc/ error)?

lxc launch ubuntu-daily:xenial xenial
lxc config set xenial security.nesting true
lxc exec xenial snap install docker
lxc exec xenial docker run ubuntu ls

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.