I was a bit frustrated in my last post about students of mine taking three weeks to install a VM in VirtualBox to play about with. I feel a bit foolish now…but I have to say the performance of VM's in VirtualBox on MacOS is utter pants. Everything just performed so sloooowly, regardless of the amount of resources the VM had dedicated to it. It was hugely frustrating. O.K, point taken kids.

So I thought about alternate solutions to running a full VM. In part this is due to the dearth of free options for virtualisation on MacOS- I could hardly ask students to start paying for software they may not use all that often. I really wanted some kind of container solution, but I was a bit stumped when it came to MacOS. Linux has a huge amount of native software for this and my entire Homelab runs almost exclusively on LXC containers. I didn't really find an equivalent for MacOS, but knew something like it had to be possible. In reality, the entire concept of containerisation seems to stem from the BSD project and Bhyve. Given MacOS is somewhat based on BSD, it had to be possible!

docker-logo

Enter…Docker!

While I use docker to host a couple of instances on my homelab, I had no idea that the version for MacOS had reached any kind of usable maturity yet. I'm fairly pleased to be wrong as it's super easy to get set up.

Step 1

First I signed up to Docker Hub (and was a bit annoyed at the lack of 2FA, but that's a rant for another day) so that I could get a copy of Docker Desktop for Mac. Fairly straightforward so far.

Step 2

Having installed Docker Desktop I configured it a bit by giving it some more system resources than the default allowed. I also unchecked “Send usage statistics”…because Privacy! I then ran;

$ docker run hello-world

to test my configuration. All fine, no issues. So far so good…

Optional Step

I also downloaded a copy of Kitematic as it gives a really nice GUI for pulling, running and stopping Docker containers. It seems to be classed as legacy software according to the Docker instructions, but it works fine for me.

Step 3

Now it's time to grab an ubuntu image. The official image on Docker Hub is a server variant which install a really minimal version. You can install this, but then you'd have to configure a window manager, desktop environment and all sorts. I initially gave this a go…and gave up as soon as I found a preconfigured image on Docker Hub. It was running the LXDE desktop, but what the hey.

A word of warning - exercise a bit of caution when randomly pulling images from the Docker Hub, it is entirely possible that some images have been corrupted and hacked by the people uploading them. The image I used was;

$ docker pull dorowu/ubuntu-desktop-lxde-vnc

Step 4

All done, now it's just time to run it! The page on Docker Hub gives a few examples of what to run, which is super helpful. If you just want to access your new container through a web browser, it's a case of running

$ docker run -p 6080:80 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc

and connecting to localhost:6080 in your browser.

Ta-daa! A space for students to mess about with and learn Linux without the performance drop-off of running VirtualBox. Docker is so lightweight that several containers can be run very easily. I am most excited about this being a potential method of getting software like Nextcloud or Mastodon running by students. I have experience in manually installing both of these and it's not for the faint of heart or newbies! With docker it becomes a case of two commands to have a service running almost fully configured!