container_linux.go 705 B

123456789101112131415161718192021222324252627282930
  1. //+build !windows
  2. package daemon
  3. import (
  4. "github.com/docker/docker/container"
  5. "github.com/docker/docker/errdefs"
  6. )
  7. func (daemon *Daemon) saveApparmorConfig(container *container.Container) error {
  8. container.AppArmorProfile = "" //we don't care about the previous value.
  9. if !daemon.apparmorEnabled {
  10. return nil // if apparmor is disabled there is nothing to do here.
  11. }
  12. if err := parseSecurityOpt(container, container.HostConfig); err != nil {
  13. return errdefs.InvalidParameter(err)
  14. }
  15. if !container.HostConfig.Privileged {
  16. if container.AppArmorProfile == "" {
  17. container.AppArmorProfile = defaultApparmorProfile
  18. }
  19. } else {
  20. container.AppArmorProfile = "unconfined"
  21. }
  22. return nil
  23. }