Skip to content

Commit 73cdd5f

Browse files
committed
Prevent systemd-binfmt from running in containers
When stemcells run as privileged containers (e.g., Docker CPI on Apple Silicon), systemd-binfmt clears the host's binfmt_misc registrations, including Rosetta, causing "exec format error" for x86_64 processes. Add a drop-in override with ConditionVirtualization=!container to skip the service in containers while preserving normal behavior on VMs. Signed-off-by: Matthew Kocher <matthew.kocher@broadcom.com>
1 parent 0b584d0 commit 73cdd5f

File tree

1 file changed

+11
-0
lines changed
  • stemcell_builder/stages/bosh_systemd

1 file changed

+11
-0
lines changed

stemcell_builder/stages/bosh_systemd/apply.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,14 @@ source $base_dir/lib/prelude_bosh.bash
1212
run_in_chroot $chroot "
1313
echo 'RemoveIPC=no' >> /etc/systemd/logind.conf
1414
"
15+
16+
# Prevent systemd-binfmt from running in containers.
17+
# When running in a privileged container (e.g., Docker CPI on Apple Silicon),
18+
# this service clears the host's binfmt_misc registrations (including Rosetta),
19+
# causing "exec format error" for all subsequent x86_64 processes.
20+
mkdir -p $chroot/etc/systemd/system/systemd-binfmt.service.d
21+
22+
cat > $chroot/etc/systemd/system/systemd-binfmt.service.d/skip-in-container.conf <<EOF
23+
[Unit]
24+
ConditionVirtualization=!container
25+
EOF

0 commit comments

Comments
 (0)