Skip to content

Nginx image: unable to run as non root in kubernetes #2924

@diconico07

Description

@diconico07

I'm unable to run the nginx image with it's default configuration within a pod with the following securityContext:

  allowPrivilegeEscalation: false
  capabilities:
    drop:
    - ALL
  seccompProfile:
    type: RuntimeDefault
  runAsNonRoot: true

Running as root with CAP_DAC_OVERRIDE, CAP_SETUID and CAP_SETGID works.

Without those logs are complaining about:

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2025/09/17 07:13:30 [emerg] 1#1: mkdir() "/var/lib/nginx/tmp/" failed (13: Permission denied)

Looking into the image, it looks like /var/log/nginx and /var/lib/nginx directories are not existing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions