Skip to content

Instantly share code, notes, and snippets.

@thimslugga
Forked from seia-soto/howto.md
Last active November 16, 2025 14:41
Show Gist options
  • Select an option

  • Save thimslugga/460d0588f5bfa99edb0747ff265f59d1 to your computer and use it in GitHub Desktop.

Select an option

Save thimslugga/460d0588f5bfa99edb0747ff265f59d1 to your computer and use it in GitHub Desktop.
How to compile lxc/incus on AlpineLinux

Download the miniroot tarball from the Alpine website and then add it to a Docker image:

FROM scratch

ENV ALPINE_ARCH x86_64
ENV ALPINE_VERSION 3.9.1

ADD alpine-minirootfs-${ALPINE_VERSION}-${ALPINE_ARCH}.tar.gz /
CMD ["/bin/sh"]

nginx Dockerfile:

FROM alpine:3.9

RUN apk update && apk add --no-cache nginx

COPY nginx.conf /etc/nginx/nginx.conf

RUN mkdir -p /usr/share/www/ /run/nginx/ && \
  rm /etc/nginx/conf.d/default.conf

EXPOSE 80

STOPSIGNAL SIGTERM

ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;"]

How to build lxc/incus on AlpineLinux (musl)

The document was written to build Incus v0.3.0. You may need a different how-to if you want to build higher versions of Incus.

  • Incus v0.3.0 (via release tarball)
  • AlpineLinux 3.18 x86_64

This how-to document will help you to build Incus for AlpineLinux. Original reference is here: https://linuxcontainers.org/incus/docs/main/installing/#from-source-build-a-release

Install dev dependencies from package manager

alpine-sdk includes common dependencies for building programs such as git. You may remove unused dependencies or install required dependencies manually. I haven't checked what's required explicitly.

apk add alpine-sdk xz acl-dev autoconf automake eudev-dev gettext-dev go intltool libcap-dev libtool libuv-dev linux-headers lz4-dev tcl-dev sqlite-dev lxc-dev

Incus replaced some Canonical tools with community fork. For example, cowsql is a community fork of dqlite.

Storage driver dependencies

apk add lvm2 thin-provisioning-tools

# activate dm-mod module
modprobe dm-mod
echo dm-mod >> /etc/modules-load.d/dm.conf

Download and unpack release archive

wget https://github.com/lxc/incus/releases/download/v0.3.0/incus-0.3.tar.xz
xz -d incus-0.3.tar.xz
tar xf incus-0.3.tar

Build Incus

Build dependencies

make deps

You'll see some environment variable definitions after make deps completes. Paste export commands into your console.

After building dependencies, you may encounter some issues depending on your system setup. You can run following commands to solve issues:

# cc1: error: /usr/local/include: No such file or directory [-Werror=missing-include-dirs]
mkdir -p /usr/local/include

# gettext.cgo2.c:(.text+0x2b9): undefined reference to `libintl_gettext'
# - module path: https://pkgs.alpinelinux.org/contents?file=libintl*&path=&name=gettext-dev&branch=edge
# - related issue: https://github.com/gosexy/gettext/issues/1
export CGO_LDFLAGS="$CGO_LDFLAGS -L/usr/lib -lintl"
export CGO_CPPFLAGS="-I/usr/include"

Build Incus

Now you can build Incus.

make

You'll also need following dependencies for incusd to run correctly:

apk add rsync squashfs-tools iptables acl attr ca-certificates cgmanager dbus dnsmasq iproute2 netcat-openbsd shadow-uidmap tar

Install Incus

I copied some commands to keep v0.3.0 installation docs here. If you're installing higher versions of Incus, please check the original documentation.

Setup environment variables

You can put following lines to console, or add them in /etc/profile.d/99incus.sh for global environment setup.

export PATH="${PATH}:$(go env GOPATH)/bin"
export LD_LIBRARY_PATH="$(go env GOPATH)/deps/cowsql/.libs/:$(go env GOPATH)/deps/raft/.libs/:${LD_LIBRARY_PATH}"

Setup unprivileged containers

echo "root:1000000:1000000000" | sudo tee -a /etc/subuid /etc/subgid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment