The LXD tutorials of Simos

howto

#1

In this post I keep an index of the tutorials I have written on LXD at https://blog.simos.info/

Introduction to LXD

  1. Online course about LXD containers
  2. Πως χρησιμοποιούμε περιέκτες LXD (LXD containers) στο Ubuntu και άλλες διανομές [in Greek]
  3. Trying out LXD containers on our Ubuntu
  4. Playing around with LXD containers (LXC) on Ubuntu

How to use LXD on xyz VPS or hosting service

  1. Trying out LXD containers on Ubuntu on DigitalOcean
  2. Trying out LXD containers on Ubuntu on DigitalOcean, with block storage
  3. How to install LXD containers on Ubuntu on Scaleway [see also next tutorial]
  4. How to run the stock Ubuntu Linux kernel on Scaleway using KEXEC and server tags
  5. How to install LXD/LXC containers on Ubuntu on cloudscale.ch
  6. A closer look at the new ARM64 Scaleway servers and LXD
  7. How to use Ubuntu and LXD on Alibaba Cloud
  8. How to set up LXD on Packet.net (baremetal servers)
  9. How to set up LXD on Civo (new UK VPS provider)
  10. A closer look at the new Hetzner cloud servers, by running LXD
  11. How to repartition a Hetzner VPS disk for ZFS on its own partition for LXD
  12. A closer look at AMD EPYC baremetal servers at packet.net (1/4)
  13. Booting up the AMD EPYC baremetal server at packet.net (2/4)
  14. Configuring LXD on the AMD EPYC baremetal server at packet.net (3/4)
  15. Benchmarking LXD on an AMD EPYC server at packet.net (4/4)

Using LXD

  1. How to initialize LXD again [HOT]
  2. How to migrate LXD from DEB/PPA package to Snap package
  3. How to set up multiple secure (SSL/TLS, Qualys SSL Labs A+) websites using LXD containers
  4. How to install neo4j in an LXD container on Ubuntu
  5. How to use lxc remote with the LXD snap
  6. How to make your LXD containers get IP addresses from your LAN using a bridge
  7. How to make your LXD containers get IP addresses from your LAN using macvlan
  8. How to use LXD instance types
  9. How to preconfigure LXD containers with cloud-init
  10. How to set the timezone in LXD containers
  11. How to use Sysdig and Falco with LXD containers
  12. How to install a Node.js app in a LXD container
  13. How to run Docker in a LXD container
  14. Installing retdec on Ubuntu [in an LXD container]
  15. How to try LXD 3.0 beta
  16. How to use LXD container hostnames on the host in Ubuntu 18.04
  17. A closer look at Minimal Ubuntu for LXD
  18. Configuring public IP addresses on cloud servers for LXD containers
  19. How to manage LXD from within one of its containers
  20. How to run Julia on Jupyter in a LXD container
  21. Setting up the ESP32 in LXD on Ubuntu
  22. Using Arduino IDE for the ESP32 in a LXD container

How to run GUI applications on LXD

  1. How to run graphics-accelerated GUI apps in LXD containers on your Ubuntu desktop
  2. How to run Wine (graphics-accelerated) in an LXD container on Ubuntu
  3. How to use the X2Go remote desktop with LXD containers
  4. How to run TeamViewer in LXD
  5. A closer look at Chrome OS using LXD to run Linux GUI apps (Project Crostini)
  6. How to easily run graphics-accelerated GUI apps in LXD containers on your Ubuntu desktop
  7. How to run HelloWorld in radare2 (installed from a snap package)

How to contribute to the development of LXD

  1. Installing the Go programming language in Ubuntu
  2. How to develop the LXD hypervisor – Part #1 (client side lxc)
  3. How to develop the LXD hypervisor – Part #2 (using multipass/KVM VM)
  4. Using distrobuilder to create container images for LXC and LXD
  5. How to create a minimal container image for LXC/LXD with distrobuilder

Tutorial ideas

  1. How to do network forwarding between the host and the containers. Use iptables. Use proxy device in lxd-2.21-next. DONE
  2. a (resumable) desktop session in the cloud A rewrite of the X2Go to focus on the desktop session. DONE
  3. Third tutorial on getting LAN IP addresses to the containers, using router static routes.
  4. Linode disk repartitioning for ZFS.
  5. Moving containers between pools (how to do with LXD 2 and LXD 3).

Little Help - Setting LXD/LXC for my testing network
Networking Issue
My containers cannot access the internet
How add another interface to lxc container with static/public ip ovh
External DHCP Not working on my enviroment
Any tutorial or tips on getting a private LXD server running on Google Cloud Platform
Static IP-address Containers
Centos 7 vs ubuntu 18 missing /etc/ssh/sshd_config?
System requirements?
I have decided to go with LXD
(Andy) #2

Very much appreciated!


#3

Thanks!

I also take requests for tutorials. If you see something missing but would be useful to have, feel free to propose it.


(Andy) #4

OK, here goes. :slight_smile:

How to access containers from your network, without the bridging techniques covered in the other guides.

I think I’m asking for a guide to using iptables to forward incoming traffic to a port on a container. I’ve seen plenty of general guides for this, and old ones which talk about lxc, but something specific to this problem when using the latest lxd, would be great. Alternatively, have I missed this in the lxd docs or getting started guides?


(Brian Mullan) #5

Maybe this will help you…

https://github.com/jorgeluiztaioque/lxd-forward


#6

The current version of LXD is 2.21. There is a patch that was accepted at https://github.com/lxc/lxd/issues/2504
and should make it in LXD 2.22 (or is it 3.0?).
It adds the functionality of a new device, the proxy device that currently can do TCP forwarding (UDP planned for the future).

It looks like this,

lxc config device add xen1 proxy0 proxy listen=tcp:192.168.50.196:80 connect=tcp:10.0.10.88:80 bind=host 

Therefore, once the new version of LXD is released, I plan to write a post about the proxy device. Then add some backup info that UDP and Unix sockets are pending work, and people can use iptables for those cases.

@bmullan thanks for the https://github.com/jorgeluiztaioque/lxd-forward link. This makes it better for new users to be able to list, create, and delete iptables commands. I’ll add this as well.


#7

Thanks for your blog posts @simos! They are very interesting.


#8

Thanks @angristan!

I have added a new post on how to run TeamViewer on LXD.
In this post we learn about lxc console. TeamViewer is a bit peculiar and unfamiliar of the LXD confinement. You get many errors, and lxc console looks like a good compromise to get it to run.
Here is the link, https://blog.simos.info/how-to-run-teamviewer-in-lxd/


#9

A new tutorial on how to repartition the disk of a Hetzner VPS so that you make space for a partition to put ZFS in there for LXD,
https://blog.simos.info/how-to-repartition-a-hetzner-vps-disk-for-zfs-on-its-own-partition-for-lxd/


#10

Added tutorial https://blog.simos.info/how-to-try-lxd-3-0-beta/

It is a gentle introduction on how to switch now to using LXD 3.0 beta, as provided by the snap package.
It takes the necessary time to explain some core snap concepts.
There is a troubleshooting section as well.

I do not know how bad it would be to downgrade from LXD 3.0 to LXD 2.0.


#11

Added the post
https://blog.simos.info/a-closer-look-at-chrome-os-using-lxd-to-run-linux-gui-apps-project-crostini/

Chrome OS can now run Linux apps, and it uses a machine container to host a Linux distro.
In this post we see how these work, and how Google’s container looks like.


#12

Added a post on how to setup the host on Ubuntu 18.04 so that you can do

ping mycontainer.lxd


#13

Added updated tutorial on how to run GUI applications in a LXD container.
This version uses LXD profiles, so it is a joy to setup the system to run GUI applications.

I have tested

  1. the host running either Ubuntu 16.04 or Ubuntu 18.04
  2. the containers running either 12.04, 14.04, 16.04 or 18.04.

Enjoy!


#14

Added a tutorial on how to do the HelloWorld with radare2/Cutter.
radare2 is a reversing framework and Cutter is the GUI.
I use a LXD GUI container to compile Cutter and run from there.


#15

Added a post on Minimal Ubuntu. These are container images that are smaller than the standard Ubuntu container images. They are about half the size of the standard images.

To use Minimal Ubuntu images in LXD,

  1. Add the following remote,

    lxc remote add --protocol simplestreams ubuntu-minimal https://cloud-images.ubuntu.com/minimal/releases/
    
  2. Launch images with Minimal Ubuntu like this:

    lxc launch ubuntu-minimal:18.04 mycontainer
    
  3. Just a reminder on how to launch the standard Ubuntu images,

    lxc launch ubuntu:18.04 mycontainer
    

Read the blog post to find the differences between the two.


#16

Added tutorial on how to configure LXD so that the containers can get directly a public IP address each.
This tutorial uses macvlan and configures statically the IP address in the container.

An alternative would be to use a bridge.

Yet another alternative would be to use IP aliases on the host to grab the IP address, then iptables to redirect network connections to the appropriate container.


#17

Added the following tutorial,

It talks about sharing the Unix socket of LXD into one of the containers of that LXD installation. In this way, it is possible to manage LXD from within a container. The sharing of LXD’s Unix socket is done using the proxy device for Unix socket <-> Unix socket proxying. Requires LXD 3.4 or newer (i.e. the LXD snap).


#18

Added a tutorial on how to run a Jupyter Notebook for the Julia computer language, in a LXD container,

In terms of LXD, it shows how to create a proxy device for TCP. It also demonstrates the difference between listening to localhost and listening to 0.0.0.0.


#19

Added two more tutorials on developing on a ESP32 board and having the whole development environment inside LXD containers.

In terms of LXD features, these tutorials demonstrate the use of the unix-char device to share the /dev/ttyUSB0 character device of the host to the container. There is nice hot-plugging going on, which means it’s easy to connect and disconnect the ESP32 without much trouble in the LXD container.

The first tutorial is about using the command-line ESP-IDE development environment in a LXD container,

The second tutorial is about setting the Android IDE in a LXD container,

It has been great going through the process. I wish to see some feedback to evaluate if it is interesting to continue doing such tutorials (compared to core LXD tutorials).


(Stéphane Graber) #20

One thought on serial devices, it’s usually best to use /dev/serial/by-id/ rather than /dev/ttyUSBX as the former will remain stable over reboots when you have more than one USB serial device connected.