LXC/LXD as an alternative to Virtualbox for local development

I don’t see an issue with either of these.

Synced folders do require global write permissions on the host system, which is obviously not ideal, but apart from that it all seems to work fine.

LXD networking has been in a state of flux and last week they moved away from LXC networking entirely as described in that blog post.

After having a few problems with the setup process I just edited the config file directly and now it’s all working nicely.

The vision is to get this working properly with Vagrant and then packaged as a proper alternative to Virtualbox for Trellis. This has been difficult because LXD itself has been a moving target recently, particularly the networking stuff.

I’m hoping things will settle down a bit with the release of 16.04.

1 Like

I got synced folders working with the following script.

It sets up subuid/gid map for your uid, and then creates a custom profile for you user that you can use with lxc launch.

Seems to work well for me, and is very flexible.

1 Like

That looks way cool.

I’ll give it a go, thanks!

Do I need to pass anything in to lxc launch to get this to work?

I am new to this community. I am very excited about the roots ecosystem, but while going through the Trellis tutorial, I fell down on the Vagrant / Virtualbox set up. It turns out that my laptop, running Ubuntu Trusty, would not run a Virtualbox VM because its hardware doesn’t support it. Then I stumbled across your post and started learning about LXC/LXD. It works just fine on my laptop.

While researching, I discovered that there is a custom Vagrant provider plug-in for LXC https://github.com/fgrehm/vagrant-lxc. I haven’t tried it yet, I am still in LXC/LXD learning mode (and I want to get through your tutorial on the manual setup) as well. I don’t know if you have tried this yet. I intend to, after I gain some familiarity with the toolset and configuration. I did want to let you know about this.


Hey @chipk great to hear you have LXD working!

I have seen the Vagrant provider plugin for LXC but unfortunately it won’t work with LXD (as far as I can tell anyway).

I owe the roots guys another blog post about this stuff, this time about using Vagrant with LXD but have struggled to find enough documentation to get it working properly.

Having said that, I have been making progress and have been in touch with Canonical about a couple of issues. A few tips for getting up and running manually without Vagrant:

That gist from @bloodearnest above will allow you to mount a shared directory without the need to make the target directory world writable.

Also, before provisioning your dev environment, check out this thread:

…and make sure to add back those sudoer password definitions.

Let me know if you need a hand.

1 Like

Wow! The learning curve on LXC/LXD has been circuitous, and required me to get my head around a lot of concepts. I am beginning to see daylight, though. Anyway, I just wanted to let you know I saw your response and thank you for your guidance and offer of assistance. I will update you when I get to the point of having Trellis working, and I definitely will take you up on your offer of help if I get stuck.


This is some great info. I’m just getting to the point where I am doing enough small WordPress sites for customers that I need a more streamlined solution than what I have been doing, which is creating individual KVM instances for each site based on a few default instances I have already created. VVV sounds great but I hate having to switch to Virtual Box and don’t have time at the moment to figure out if I can make it work with KVM. Have you made any further progress on getting LXD and Vagrant working together?

Unfortunately not.

I’ve found that just working with the LXC/LXD tools in combination with trellis gives great results. I just setup the .dev domains in my local /etc/hosts file and handle everything manually. I like the control that gives and don’t really feel the need for Vagrant anymore.

I’m trying to make this work over my local network on a spare box with Mint installed. Stuck trying to get an ssh connection through to the VM.

I’m not familiar with Mint, but assuming it has all of the required Ubuntu LXD software available you probably just need to configure LXD networking.

This article should help:

1 Like

Thanks Rob. Yes Mint is basically Ubuntu and LXD/LXC is working as expected.

1 Like

Hi Sunil,

Let me know how you get on.

Once you have the networking sorted it should work well. Just remember that if you are using an LXD host for development you will need to provision it manually with Trellis which will require you to add back a couple of lines in files removed in this commit:

Great post treb0r.

For those OSX (now macOS) using readers you kindly apologised to I’d like to point them to a mini lxd datacenter I’ve whipped up which should get them into a similar fun space.

1 Like

Wow. Now that is pretty hardcore.

Apparently LXD is going to be available and working in Windows too.

Yes a very interesting direction things are going in. I wonder if its possible to do the lxd install using the various hacks out there for getting a full Ubuntu under the windows 10 bash feature?

Well according to a Canonical developer I have spoken with, Microsoft has committed to ‘fully integrate’ Ubuntu into Windows 10. They already have LXD working in the cloud and he says it’s coming to the desktop soon.

I’m old enough to remember MacOS before OSX, and it really seemed that Apple were creating the perfect OS with OSX by adding a solid UNIX foundation. These days it seems that Apple are doing everything they can to hinder developers and the new macOS seems squarely targeted at consumers.

Meanwhile Microsoft are quietly bringing Linux to the party. What a time to be alive :grinning:.

Interesting article about Microsoft and Ubuntu here:

Very interesting. After reading that and feeling somewhat inspired, I spent time tinkering around with windows 10. I managed to get LXD installed under the new Windows Subsystem for Linux, It turns out there is no actual linux kernel, but rather a set of api’s that allow native elf binaries to happily run. “lxd init” failed and complained about not being able to open a socket and I kind of doubt they would have implemented the required emulation needed for the kernel control groups and namespaces to work properly. Unfortunately ZFS is not going to work either however, I guess it is early days yet. :slight_smile:

Well who knows. I don’t have a Windows machine here so I just go on what I read and what people tell me.

This article from last year seems to suggest that it is coming down the line:

Given the nature of this discussion, I though you would be interested in following the development of a tool we’ve been working on, LXDock which is a replacement for Vagrant built around LXD. It works pretty well as it is, but it’s still in heavy development.

1 Like