---
title: Shared host network 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 network namespace
---

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

# Shared host network 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-network-namespace` 

**Platform:** DockerCompose

**Severity:** Medium

**Category:** Resource Management

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

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

### Description{% #description %}

Setting `network_mode: host` places a container directly on the host's network stack, removing all network isolation and exposing every host network interface, port, and routing table to the container. This can allow a compromised container to intercept or inject traffic on any host network interface and expose services bound to loopback addresses. Services should use Docker-managed networks rather than `host` networking.

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

```yaml
services:
  bridge:
    image: alpine
    network_mode: bridge
  default:
    image: alpine
```

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

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