Skip to content

Instantly share code, notes, and snippets.

View webmasterOVN50's full-sized avatar
💭
I may be slow to respond.

Michael Adams webmasterOVN50

💭
I may be slow to respond.
View GitHub Profile

How to Install Nix in an LXD Container

Steps to install the Nix package manager inside an Ubuntu 20.04 LXD container using the images:ubuntu/focal image:

  1. On the LXD host, create an Ubuntu 20.04 container:
    lxc init images:ubuntu/focal container1
    
  2. On the LXD host, enable nested security on the container:
@webmasterOVN50
webmasterOVN50 / readme.md
Created November 21, 2022 21:16 — forked from maxivak/readme.md
Multiple networks in LXC container

Network for LXC container

Host device as bridge

  • persisted in host's /etc/network/interfaces the container's veth virtual ethernet interface can share the network link on the physical interface of the host (eth0). So the container resides on the same ethernet segment and talks to the same dhcp server as the host does.

Additonal bridge device

  • setup manually with brctl

Useful LXD commands

Summarized from https://stgraber.org/2016/03/19/lxd-2-0-your-first-lxd-container-312/.

Interestingly, the LXD command line client is named.... lxc!

List available containers

lxc image list ubuntu:        # ubuntu: is officially supported image source
lxc image list images:        # images: is an unsupported source
lxc image alias list images:  # lists user-friendly names
@webmasterOVN50
webmasterOVN50 / events-websock.js
Created August 8, 2022 13:33 — forked from CalebEverett/events-websock.js
Lxd api example: lxc exec and operations websocket via nodejs
const fs = require('fs')
const WebSocket = require('ws');
const wsoptions = {
cert: fs.readFileSync('../../.config/lxc/client.crt'),
key: fs.readFileSync('../../.config/lxc/client.key'),
rejectUnauthorized: false
}
var ws = new WebSocket('wss://127.0.0.1:8443/1.0/events?type=operation', wsoptions);
@webmasterOVN50
webmasterOVN50 / cloud-init.sh
Created July 19, 2022 18:26 — forked from madalinignisca/cloud-init.sh
WordPress on MicroK8s
#!/bin/bash
set -euo pipefail
USERNAME=wpk8s # TODO: Customize the sudo non-root username here
# Create user and immediately expire password to force a change on login
useradd --create-home --shell "/bin/bash" --groups sudo "${USERNAME}"
passwd --delete "${USERNAME}"
chage --lastday 0 "${USERNAME}"