Docker won't start inside Incus container ------------------------------------------ # Issue Running Docker inside Incus has worked for years, but a recent Ubuntu package update caused it to fail. ## Symptoms Docker containers won't start with the following error: ``` docker compose up Attaching to neo4j Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: open sysctl net.ipv4.ip_unprivileged_port_start file: reopen fd 8: permission denied ``` The issue is AppArmor on Incus containers. The host has AppArmor, and Incus applies an AppArmor profile to containers with `security.nesting=true` that blocks Docker from writing to `/proc/sys/net/ipv4/ip_unprivileged_port_start`. # Solution (Automated) The fix requires **both** host-side and container-side changes. These are now automated in our infrastructure: ## 1. Terraform - Host-side fix In `terraform/containers.tf`, all containers with `security.nesting=true` now include: ```terraform config = { "security.nesting" = true "raw.lxc" = "lxc.apparmor.profile=unconfined" } ``` This tells Incus not to load any AppArmor profile for the container. ## 2. Ansible - Container-side fix In `ansible/docker/deploy.yml`, Docker deployment now creates a systemd override: ```yaml - name: Create AppArmor workaround for Incus nested Docker ansible.builtin.copy: content: | [Service] Environment=container="setmeandforgetme" dest: /etc/systemd/system/docker.service.d/apparmor-workaround.conf ``` This tells Docker to skip loading its own AppArmor profile. # Manual Workaround If you need to fix this manually (e.g., before running Terraform/Ansible): ## Step 1: Force unconfined mode from the Incus host ```bash # On the HOST (pan.helu.ca), not in the container incus config set raw.lxc "lxc.apparmor.profile=unconfined" --project agathos incus restart --project agathos ``` ## Step 2: Disable AppArmor for Docker inside the container ```bash # Inside the container sudo mkdir -p /etc/systemd/system/docker.service.d sudo tee /etc/systemd/system/docker.service.d/apparmor-workaround.conf <