---
title: Shared host user namespace
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Infrastructure as Code (IaC)
  Security > IaC Security Rules > Shared host user namespace
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Shared host user namespace

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**Id:** `dockercompose-shared-host-user-namespace` 

**Platform:** DockerCompose

**Severity:** Medium

**Category:** Resource Management

#### Learn More{% #learn-more %}

- [Provider Reference](https://docs.docker.com/reference/compose-file/services/#userns_mode)

### Description{% #description %}

Setting `userns_mode: host` disables user namespace remapping for a service, causing container user IDs—including `root` (UID 0)—to map directly to the same UIDs on the host. A container process running as root inside the container therefore has root-level privileges on the host, significantly increasing the impact of a container compromise. Services should omit `userns_mode` or use a remapped namespace to maintain user isolation.

## Compliant Code Examples{% #compliant-code-examples %}

```yaml
services:
  private:
    image: alpine
    userns_mode: private
  default:
    image: alpine
```

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```yaml
services:
  risky:
    image: alpine
    userns_mode: host
```
