Installing LXD inside a Docker Container (on MacOS)

I am trying to setup LXD inside a docker container for development and testing, however I am struggling, probably because the snap thing.

Any help would be much appreciated.

Hi!

Perhaps you want to perform the opposite?
That is, create a LXD system container, and in there setup Docker.

LXD provides system containers, which are similar to virtual machines but much more lightweight. The way they work is similar to Docker, but in LXD you have system containers compared to application containers in Docker.

No I am trying to setup LXD inside a docker container. I am on a MAC so I cant install LXD locally, right now I am having to using virtualbox, which I prefer not too.

Update:
There is only a version of the LXD-client (and NO server) for MacOS:
https://linuxcontainers.org/lxd/getting-started-cli/#macos-builds

Well I don’t use MacOS myself, but there are versions for MacOS:

On Mac you can only install LXC, not LXD.

Update:
I see one can only install the LXD-client and not the Server (on MacOS and Windows).

:thinking:
I might be wrong, but it reads this:

To install the feature branch of LXD, run:
brew install lxc

So maybe you confuse LXD and LXC.

Short summary:
lxc is (in this case) the LXD-client (I know its confusing, but I guess the name won’t be changed)
##########################################

Regarding your inital problem:
I guess you should clarify the title “lxd inside docker container on macos” and you might give some more details, what you tried so far and what problems you exactly encountered.

But my guesses would be:

  • Maybe Docker works differently on Mac than on Linux It indeed works differenty, see below.
  • In general LXD will need much access to the host system (thus it needs to run nested etc. to support running LXD inside LXD for example: https://ubuntu.com/blog/lxd-2-0-lxd-in-lxd-812) and docker might not provide that out of the box.

Also did you try to ask here:


or here:

because it seems to be more a docker question, than an lxd question.

Update 2:
Interesting I found this:

Functionally, there is no difference. Startup is slower from cold on OSX because as other commenters pointed out, the underlying Linux VM

Source: https://www.reddit.com/r/docker/comments/bh8rpf/docker_performance_on_macos_vs_native_linux/elqy277/

So you might gain nothing trying to use docker, because it also uses a VM (on MacOS).
Which is only logical because containers require the hosts kernel and the kernel of macos is different from the linux kernel.

Both Docker and LXD require a Linux distribution, with a Linux kernel, to work.

Docker Desktop for Mac and Windows is a mix of the Docker Desktop Client, and a VM running in VirtualBox with a Linux distribution.

Docker Desktop for Mac is just a nicely wrapped package that installs the Docker Desktop interface, and launches for you a VirtualBox VM with a specialized boot2docker Linux distribution.

In comparison, LXD provides only the client software for Mac. You have to setup yourself a Linux distribution in a VM on your Mac. In that Linux distribution, you setup LXD, and you enable it to be accessible remotely. That is, when you run sudo lxd init, you answer Yes at the question on whether to access the LXD server remotely. Finally, you configure your Mac LXD client (lxc package) to access this remote LXD server in the VM.

Most likely you are not able to install LXD in Docker on Mac, because the Linux distribution that houses Docker is a very specialized Linux distribution.

1 Like