30.11.2025

Privileged vs Non-privileged Docker Containers: Differences, Security, and Use Cases

In Docker, containers can be run in two main modes: privileged and non-privileged. This choice determines the level of access the container will have to the host’s resources and system functions. Understanding the differences between these modes is extremely important: it affects both the security of your system and the functionality of applications inside the containers. The non-privileged mode is suitable for most daily tasks, providing isolation and protection for the host, while privileged gives the container full access to host devices, the kernel, and network interfaces, which is only necessary in specific cases such as driver testing or hardware management. A conscious choice of the execution mode helps balance functionality and security.

Non-privileged Containers (Default)

What it is:

Features:

Real use cases: Web services, databases, applications that don’t need to change host system settings.

Example of running:

docker run -it ubuntu:22.04 bash

This container runs in non-privileged mode by default.

Privileged Containers

What it is:

The container can:

Features:

Example of running:

docker run --privileged -it ubuntu:22.04 bash

When to use:

  1. For containers that need access to host devices (e.g., USB, GPU).
  2. For system containers emulating host services.
  3. For testing and debugging.

Permission Differences

Characteristic Non-privileged Privileged
Host kernel access No Yes
Access to /dev devices Limited Full
Kernel module management No Yes
Modifying host network interfaces No Yes
Security risk Low High
Use case Regular applications, services System services, testing, device access
Example of running docker run -it image bash docker run --privileged -it image bash

Recommendations

In most cases, it’s better to run containers in non-privileged mode — it’s safe and ideal for regular applications and services that don’t require direct host access. The privileged mode should only be used when truly necessary, for example, if your application needs to manage devices, kernel modules, or host network interfaces. Even in these cases, think about security and don’t grant more permissions than necessary. Often a good alternative to full --privileged is granting specific capabilities via --cap-add or access to needed devices via --device, for example:

docker run --cap-add=NET_ADMIN --device=/dev/sda1 -it ubuntu:22.04 bash

This way, you maintain control, enhance security, and allow the container to perform necessary tasks without unnecessary risks.

Cheat Sheet

Characteristic Non-privileged Privileged
Host kernel access No Yes
Access to /dev devices Limited Full
Kernel module management No Yes
Modifying host network interfaces No Yes
Security risk Low High
Use case Regular applications, services System services, testing, device access
Example of running docker run -it image bash docker run --privileged -it image bash