Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Run privileged commands more securely in OpenShift Dev Spaces

December 12, 2025
Mario Loriedo Pradipta Banerjee Ilya Buziuk
Related topics:
Application modernizationContainersDeveloper productivityDeveloper toolsIDEsKubernetesOpen sourceVirtualization
Related products:
Developer ToolsetRed Hat OpenShift Dev SpacesRed Hat OpenShift

    Running containers as a privileged user in a Red Hat OpenShift cluster is a security issue. Installing a package, running nested containers, and other tasks that require sudoers privileges are usually not allowed in the cloud. When containers run with root privileges, they may compromise the host system, either intentionally or unintentionally.

    This is problematic when running cloud development environments (CDEs) in an OpenShift cluster, such as Red Hat OpenShift Dev Spaces. Developer tools often require privileges that are beyond the default, restricted, privileges of an OpenShift container.

    The challenge, therefore, is to run CDE in privileged containers without compromising cluster security. This may look contradictory, but as we will discuss in this article, the enhanced isolation provided by Kata containers makes it possible.

    Note

    This article explains a technique for running privileged commands in CDEs, including commands to install new packages. While installing a new tool can be useful when experimenting with it, we discourage updating CDEs in this manner. Containers should be considered immutables. Any newly installed package will disappear after restarting the CDE. For the recommended way to update an OpenShift Dev Spaces CDE, please refer to this blog.

    Kata containers to the rescue

    Kata containers provide pod sandboxing by leveraging virtualization. Each pod runs in a VM, isolating its containers from the host system. This isolation allows running privileged pods while still protecting the host. Running as root inside the container is no longer a security issue.

    The OpenShift sandboxed containers solution brings Kata containers support to OpenShift.

    The diagram in Figure 1 compares a standard pod to an OpenShift sandboxed container pod. Note the additional green VM layer for isolation.

    Sandboxed Pod
    Figure 1: This diagram compares a standard pod to an OpenShift sandboxed container pod.

    You can read more about OpenShift sandboxed containers in this blog post.

    A policy to run privileged and secured containers

    Service accounts, along with roles and roleBindings, define the actions a user or application can perform within the OpenShift cluster. To enable the creation of privileged containers, we define a privileged role and assign it to a specific service account. This service account will have the necessary permissions to create privileged containers.

    Further, to ensure these privileged containers don't compromise the host, we can implement a Kyverno policy that enforces the use of sandboxed (Kata) containers for any pods created by this privileged service account. This ensures that any privileged container cannot impact the host.

    Configuring OpenShift sandboxed containers

    Follow the official product guide to deploy OpenShift sandboxed containers on bare metal worker nodes.

    Red Hat OpenShift Dev Spaces runs cloud development environments (CDEs). The default IDE running in the pod is Visual Studio Code. By default, the CDEs are unprivileged, so dnf install and podman run won’t work. But if you have configured the cluster like the Kata containers and privileged service account in the previous section (limited by a Kyverno policy for each developer namespace), then we can configure Dev Spaces to run the CDE as privileged Kata containers, where dnf install and podman run will work.

    Figure 2 shows that, when Dev Spaces uses Kata containers, privileged commands such as podman run -ti --rm hello-world execute successfully.

    The image shows that "podman run" is executed successfully from Dev Spaces terminal
    Figure 2: This image shows a privileged command executed successfully in Dev Spaces.

    You can find the step-by-step instructions on how to set up a cluster, OpenShift sandboxed containers operator, OpenShift Dev Spaces operator, and Kyverno in the Red Hat Developer repository. 

    Limits and alternatives

    Running Kata containers requires a Kubernetes cluster with bare-metal worker nodes. We did our tests using an OpenShift cluster with AWS m5.metal worker nodes. The OpenShift cluster bot provisions such a cluster with the launch 4.20 metal,ovn command. 

    Another approach to run privileged commands in a CDE is to enable user namespaces in containers so the container's root user doesn’t match the node's root user. Recently, we added this feature to OpenShift 4.20, which is extensively covered in this article.

    Final thoughts

    In this article, you learned about a technique for running privileged commands within cloud development environments (CDEs) in OpenShift Dev Spaces, addressing the common security issue of running containers as a privileged user in an OpenShift cluster. The solution is using Kata containers (provided by OpenShift sandboxed containers), which use virtualization to run each pod in a separate VM. This isolation protects the host system, allowing privileged containers to run without compromising cluster security. For more information, you can visit our GitHub repository.

    Related Posts

    • Cloud bursting with confidential containers on OpenShift

    • Confidential VMs: The core of confidential containers

    • IBM Hyper Protect with OpenShift sandboxed containers

    • AI meets containers: My first step into Podman AI Lab

    • How to debug confidential containers securely

    Recent Posts

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    What’s up next?

    Enhance security with automation_Share

    Enhance security with automation

    Red Hat
    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI