Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pkg/api/handlers/compat/containers_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,27 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C
parsedTmp = append(parsedTmp, finalString)
}



// If the podman service is running inside a container (e.g. Quadlet/systemd),
// and the Docker-compat client did not request a specific AppArmor profile,
// inject "apparmor=unconfined" to avoid crun failing to write
// /proc/thread-self/attr/apparmor/exec on kernel >= 6.17 where the outer
// container's AppArmor policy blocks change_profile.
// See: https://github.com/containers/podman/issues/28992
if _, statErr := os.Stat("/run/.containerenv"); statErr == nil {
hasApparmorOpt := false
for _, opt := range cc.HostConfig.SecurityOpt {
if strings.HasPrefix(opt, "apparmor=") {
hasApparmorOpt = true
break
}
}
if !hasApparmorOpt {
cc.HostConfig.SecurityOpt = append(cc.HostConfig.SecurityOpt, "apparmor=unconfined")
}
}

// Note: several options here are marked as "don't need". this is based
// on speculation by Matt and I. We think that these come into play later
// like with start. We believe this is just a difference in podman/compat
Expand Down