Is it possible to build Linux kernel inside an LXC container?

Solution 1:

Building software is just regular work. It doesn’t (usually) need special privileges or access or anything. In fact, it is often done in sandboxes already, to prevent malicious or accidental modification of unrelated files.

So the answer is simply yes, this is possible.

I recommend you build a .deb package from the kernel. You can use make-kpkg to do this. There’s a guide in the Ubuntu handbook.