mraerino/unifi-os-server-vm-image

★ 1Forks 0HCLGitHub ↗Compare

README

Packaging the Unifi OS Server for qemu in Docker

This is in prep for turning this into a HAOS (Home Assistant OS) app.

Build it yourself

Prerequisites

  • Qemu
  • Packer
  • Docker

Building

  • packer build uos_server.pkr.hcl - this will produce the VM image
    • on ARM macs, use packer build -var host_is_arm_mac=true -var target_arch=arm64 uos_server.pkr.hcl
  • docker build . -t local/unifi-os-server - this will copy the VM image into a container image
    • for x86 builds to work, you probably have to pass --build-arg BASE=qemux/qemu

Note: Building for other architectures than arm64 is not tested yet

Running

Note: This requires support for nested virtualization in your Docker host

docker run -it --rm --name unifi-os-server --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN --stop-timeout 120 --sysctl net.ipv4.ip_forward=1 -p 11443:11443 local/unifi-os-server

Apple Silicon Tips

To get nested virtualization working on ARM Macs, here are some tips:

  • Use Lima and start a VM with nested virtualization:

    limactl start --set '.nestedVirtualization=true' template:docker
    export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')
    
    • enter the Lima shell: limactl shell docker
    • sudo usermod -G kvm $(whoami)
    • sudo sh -c "echo '$(whoami):$(stat -c %g /dev/kvm):1' >> /etc/subgid"
    • leave shell
    • limactl restart docker
  • now you can add --group-add 1073741825 to the docker run command and it should work

Contributors

mraerino

Issues