---
title: The container's root filesystem should be set to read-only
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > The container's root filesystem should
  be set to read-only
---

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

# The container's root filesystem should be set to read-only
Classification:complianceFramework:cis-dockerControl:5.13 
## Description{% #description %}

Containers should mount their root filesystem read-only.

## Rationale{% #rationale %}

A read-only root filesystem keeps an attacker from changing the binaries and configuration of the container, and makes the data a container writes explicit as volumes.

## Audit{% #audit %}

Inspect the containers:

```bash
docker ps --quiet --all | xargs docker inspect --format '{{ .Name }}: ReadonlyRootfs={{ .HostConfig.ReadonlyRootfs }}'
```

Datadog passes the rule when a container's root filesystem is read-only and fails it otherwise.

## Remediation{% #remediation %}

Run the container with `--read-only`, with volumes or `--tmpfs` mounts where it writes:

```bash
docker run --read-only --tmpfs /tmp <image>
```

## Impact{% #impact %}

Writes outside the volumes fail.

## Default value{% #default-value %}

Containers can write to their root filesystem.

## References{% #references %}

1. [https://docs.docker.com/engine/storage/volumes/](https://docs.docker.com/engine/storage/volumes/)
1. [https://docs.docker.com/engine/storage/volumes/#use-a-read-only-volume](https://docs.docker.com/engine/storage/volumes/#use-a-read-only-volume)
1. [https://docs.docker.com/reference/cli/docker/container/run/#mount-tmpfs—tmpfs](https://docs.docker.com/reference/cli/docker/container/run/#mount-tmpfs---tmpfs)
