> ## Documentation Index
> Fetch the complete documentation index at: https://docs.archil.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mount in a container

Mount Archil into a container when you need data that survives individual container lifetimes, or if you need to share data
across multiple containers. Containers, unlike regular Linux servers, require special permissions in order to mount external
file systems.

A container that runs `archil mount` needs `/dev/fuse`, root, and the `CAP_SYS_ADMIN` capability. See
[Requirements](https://docs.archil.com/mounting/linux.md#requirements) for the full list, including network ports.

The best way to mount Archil into a container depends on the platform that you're using and the permissions that you have:

* **Local docker containers** support mounting Archil if they are started with `--privileged`, or mount to the host machine
  and add Archil to your container as a Docker volume.
* **Kubernetes pods** support mounting Archil via the [CSI driver](https://docs.archil.com/reference/csi-driver.md), follow instructions to install and use the CSI driver
  on K8s deployments
* **Cloud container platforms** (such as AWS Lambda, ECS Fargate, or Modal container sandboxes) often do not support mounting
  Archil because they do not give users sufficient permission to mount external file systems. For these users, we recommend
  using [Serverless execution](https://docs.archil.com/compute/serverless-execution.md) to send code that needs the disk to Archil directly.
* **Cloud sandboxes** (such as Daytona, E2B, and Modal VM sandboxes) often support mounting Archil directly. See the
  [Daytona](https://docs.archil.com/guides/platforms/daytona.md), [E2B](https://docs.archil.com/guides/platforms/e2b.md), and [Modal](https://docs.archil.com/guides/platforms/modal.md) guides, or
  consult your provider's documentation for the best way to mount Archil.

The remainder of this article is about how to mount into a local Docker container. For Docker Compose files, mount
propagation, sharing a disk across containers and hosts, and clean shutdown, see
[Docker and Docker Compose](https://docs.archil.com/mounting/docker-compose.md).

## Mounting into a privileged container

You can easily mount an Archil disk into a privileged container, because it has full access to the host's Linux kernel,
and has permissions to mount external file systems. These steps are the same as mounting on a regular Linux machine.

**1. Add the client to your Dockerfile**

Add the following lines to your Dockerfile to automatically install the Archil CLI to mount Archil disks, and
create the folder where you plan to mount Archil.

```bash theme={null}
RUN curl -s https://archil.com/install | sh
RUN mkdir /mnt/archil
```

**2. Start your privileged container**

Start your container with the `--privileged` flag to give your container permission to mount external file systems.

```bash theme={null}
docker run --privileged <image>
```

**3. Authorize your server**

Each container that connects to the Archil disk needs to be authorized. You can managed which servers are authorized
in the Archil console, by navigating to the disk that you want to use, then selecting **Connections** in the left-bar,
and clicking **Add User** to authorize a new server.

Select **Disk Token**, and save the token somewhere you can retrieve it, you will not be able to see it again.

**4. Mount the disk**

Using the token that you just saved from the console, you can now mount the disk with `archil mount`.

```bash theme={null}
export ARCHIL_MOUNT_TOKEN="<disk-token>"
sudo --preserve-env=ARCHIL_MOUNT_TOKEN archil mount <disk-name> /mnt/archil --region <disk-region>
```

## Mounting as a Docker volume

**1. Mount your disk to the host**

Follow the instructions for either [mounting to Linux](https://docs.archil.com/mounting/linux.md) or [mounting to macOS](https://docs.archil.com/mounting/macos.md) to
mount your Archil disk to the host running docker.

For example, for Linux, assuming you have the Archil CLI installed:

```bash theme={null}
export ARCHIL_MOUNT_TOKEN="<disk-token>"
sudo --preserve-env=ARCHIL_MOUNT_TOKEN archil mount <disk-name> /mnt/archil --region <disk-region>
```

**2. Run your container**

Once your disk is mounted to the host, you can run your container with the `docker run` command, using the `--volume` flag to bind-mount the disk to the container.
The `rslave` option lets the container see the disk even if the host mounts or remounts it after the container starts.

```bash theme={null}
docker run --volume /mnt/archil:/mnt/archil:rslave <image>
```

## Comparisons

* [Archil vs Amazon S3 Files for agent workspaces](https://archil.com/article/archil-vs-amazon-s3-files-for-agent-workspaces)
* [Archil vs Amazon EFS for AI agents](https://archil.com/article/archil-vs-amazon-efs-for-ai-agents)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.