Enable AppArmor for Supervisor in devcontainers#170
Merged
Conversation
Enable AppArmor support so apps developers can develop and test AppArmor profiles for their apps in the devcontainer environment. - Add mount-securityfs.service to mount securityfs inside the container (the kernel doesn't do this automatically in containers) - Add hassio-apparmor.service to download and load the hassio-supervisor profile from version.home-assistant.io on first boot - Install apparmor package in both devcontainer images - Switch supervisor_run from apparmor=unconfined to apparmor=hassio-supervisor Both services use ConditionSecurity=apparmor to gracefully skip on hosts without AppArmor kernel support.
sairon
approved these changes
Apr 14, 2026
Member
sairon
left a comment
There was a problem hiding this comment.
Looks good both with AA enabled and with unloaded kernel module on a Linux host, so 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable AppArmor support in devcontainers so apps developers can develop and test AppArmor profiles for their apps.
Add
mount-securityfs.serviceto mount securityfs inside the container (the kernel doesn't do this automatically in containers). A regular systemd.mountunit cannot be used here because systemd refuses to manage mount units for API filesystem paths like/sys/kernel/security.Add
hassio-apparmor.serviceand loader script to download and load thehassio-supervisorAppArmor profile on first bootInstall
apparmorpackage in both devcontainer imagesSwitch
supervisor_runfromapparmor=unconfinedtoapparmor=hassio-supervisorNotes
Both systemd services use
ConditionSecurity=apparmorto gracefully skip on hosts without AppArmor kernel support.Tested on a host without AppArmor: Docker's
--security-opt apparmor=hassio-supervisordoes not cause a failure when the kernel has no AppArmor support, sosupervisor_runstill works. Supervsior simply detects AppArmor is missing:auditddoes not work inside the container due to missing permissions on the kernel audit subsystem (audit is host-global and cannot be controlled from within a container). AppArmor denials are still logged to the kernel ring buffer and visible viadmesgorjournalctl -k. For full audit logging, runauditdon the host OS directly.Fixes: #157