How to fix this issue? sudo: The "no new privileges" flag is set, which prevents sudo from running as root. sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.

EMMANUEL 1 Reputation point
2024-09-03T13:17:55.44+00:00

Please how do I fix this error on an Ubuntu Linux running in Azure VM?
sudo: The "no new privileges" flag is set, which prevents sudo from running as root.

sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,790 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Akshay kumar Mandha 385 Reputation points Microsoft Vendor
    2024-09-04T14:53:30.54+00:00

    Hi EMMANUEL,
    Thank you for your patience while we are reviewing the issue

    Based upon your query, If the ubuntu linux VM in azure is running inside a container you need adjust the container's security setting to disable the "no new privileges" flag. If it is docker containers, use the below command

    docker run --security-opt no-new-privileges = false
    

    Optionally when starting the container, or update your docker compose file to include below config

    services:
      your_service:
        image: your_image
        security_opt:
          - no-new-privileges=false
    

    For Kubernetes or other container environments, update the pod security policies or security context to allow privilege escalation. If an answer has been helpful, please consider accepting the answer  and "Upvote" to help increase visibility of this question for other members of the Microsoft Q&A community. User's image


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.