選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

Mounting from Amazon Elastic Container Service - Amazon File Cache
此頁面尚未翻譯為您的語言。 請求翻譯

Mounting from Amazon Elastic Container Service

You can access your cache from an Amazon Elastic Container Service (Amazon ECS) Docker container on an Amazon EC2 instance. You can do so by using either of the following options:

  1. By mounting your cache from the Amazon EC2 instance that is hosting your Amazon ECS tasks, and exporting this mount point to your containers.

  2. By mounting the cache directly inside your task container.

For more information about Amazon ECS, see What is Amazon Elastic Container Service? in the Amazon Elastic Container Service Developer Guide.

We recommend using option one (Mounting from an Amazon EC2 instance hosting Amazon ECS tasks) because it provides better resource use, especially if you start many containers (more than five) on the same EC2 instance, or if your tasks are short-lived (less than five minutes).

Use option two (Mounting from a Docker container), if you're unable to configure the EC2 instance, or if your application requires the container's flexibility.

Note

Mounting your cache on an AWS Fargate launch type isn't supported.

The following sections describe the procedures for each of the options for mounting your cache from an Amazon ECS container.

Mounting from an Amazon EC2 instance hosting Amazon ECS tasks

This procedure shows how you can configure an Amazon ECS on an EC2 instance to locally mount your cache. The procedure uses volumes and mountPoints container properties to share the resource and make this cache accessible to locally running tasks. For more information, see Launching an Amazon ECS container instance in the Amazon Elastic Container Service Developer Guide.

This procedure is for an Amazon ECS-Optimized Amazon Linux 2 AMI. If you're using another Linux distribution, see Installing the Lustre client.

To mount your cache from Amazon ECS on an EC2 instance
  1. When launching Amazon ECS instances, either manually or using an Auto Scaling group, add the lines in the following code example to the end of the User data field. Replace the following items in the example:

    • Replace cache_dns_name with the actual cache's DNS name.

    • Replace mountname with the cache's mount name.

    • Replace mountpoint with the cache's mount point, which you need to create.

    #!/bin/bash ...<existing user data>... fsx_dnsname=cache_dns_name fsx_mountname=mountname fsx_mountpoint=mountpoint amazon-linux-extras install -y lustre mkdir -p "$fsx_mountpoint" mount -t lustre ${fsx_dnsname}@tcp:/${fsx_mountname} ${fsx_mountpoint} -o relatime,flock
  2. When creating your Amazon ECS tasks, add the following volumes and mountPoints container properties in the JSON definition. Replace mountpoint with the cache's mount point (such as /mnt).

    { "volumes": [ { "host": { "sourcePath": "mountpoint" }, "name": "Lustre" } ], "mountPoints": [ { "containerPath": "mountpoint", "sourceVolume": "Lustre" } ], }

Mounting from a Docker container

The following procedure shows how you can configure an Amazon ECS task container to install the lustre-client package and mount your cache in it. The procedure uses an Amazon Linux (amazonlinux) Docker image, but a similar approach can work for other distributions.

To mount your cache from a Docker container
  1. On your Docker container, install the lustre-client package and mount your cache with the command property. Replace the following items in the example:

    • Replace cache_dns_name with the actual file cache's DNS name.

    • Replace mountname with the cache's mount name.

    • Replace mountpoint with the cache's mount point.

    "command": [ "/bin/sh -c \"amazon-linux-extras install -y lustre; mount -t lustre cache_dns_name@tcp:/mountname mountpoint -o relatime,flock;\"" ],
  2. Add SYS_ADMIN capability to your container to authorize it to mount your cache, using the linuxParameters property.

    "linuxParameters": { "capabilities": { "add": [ "SYS_ADMIN" ] } }
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。