ECS Fargateでサポートされたtmpfsマウントを試してみた
2026年1月6日、Amazon ECS は AWS Fargate および ECS Managed Instances において、tmpfs のマウントをサポートするアップデートがありました。
今回、Fargateで tmpfs をマウントする 検証用タスクを作成し、その動作をログなどから確認する機会がありましたので紹介します。
検証環境
検証には以下の構成を使用しました。
- リージョン: us-west-2 (Oregon)
- 起動タイプ: AWS Fargate
- OS: Amazon Linux 2023
- リソース: CPU 256 / Memory 512 MB
CloudFormation テンプレート
検証に使用したテンプレートは以下の通りです。
CloudFormationテンプレート全文
AWSTemplateFormatVersion: '2010-09-09'
Description: 'ECS Fargate with tmpfs mounts on default VPC'
Resources:
# ECS Cluster
ECSCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: tmpfs-test-cluster
# CloudWatch Log Group
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: /ecs/tmpfs-test
RetentionInDays: 7
# IAM Roles (Execution & Task)
TaskExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
TaskRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: ECSExecPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- ssmmessages:CreateControlChannel
- ssmmessages:CreateDataChannel
- ssmmessages:OpenControlChannel
- ssmmessages:OpenDataChannel
Resource: '*'
# Task Definition with tmpfs
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: tmpfs-test-task
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
Cpu: '256'
Memory: '512'
ExecutionRoleArn: !GetAtt TaskExecutionRole.Arn
TaskRoleArn: !GetAtt TaskRole.Arn
ContainerDefinitions:
- Name: tmpfs-container
Image: amazonlinux:2023
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref LogGroup
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: ecs
LinuxParameters:
Tmpfs:
- ContainerPath: /mnt/tmpfs
Size: 256
- ContainerPath: /tmp
Size: 128
MountOptions:
- noexec
- nosuid
Command:
- /bin/sh
- -c
- |
echo "=== tmpfs mounts verification ==="
df -h | grep tmpfs
echo ""
echo "=== Creating test file in /mnt/tmpfs ==="
echo "test data $(date)" > /mnt/tmpfs/test.txt
cat /mnt/tmpfs/test.txt
echo ""
echo "=== Verification complete ==="
sleep 3600
# Network Resources
FargateSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security group for Fargate tmpfs test
VpcId: vpc-********
ECSService:
Type: AWS::ECS::Service
Properties:
ServiceName: tmpfs-test-service
Cluster: !Ref ECSCluster
TaskDefinition: !Ref TaskDefinition
DesiredCount: 1
LaunchType: FARGATE
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
SecurityGroups:
- !Ref FargateSecurityGroup
Subnets:
- subnet-********
LinuxParameters
タスク定義内の LinuxParameters で、2つの tmpfs マウントを定義しました。
/mnt/tmpfs: サイズ 256MB、オプションなし/tmp: サイズ 128MB、セキュリティオプション(noexec,nosuid)あり
"linuxParameters": {
"devices": [],
"tmpfs": [
{
"containerPath": "/mnt/tmpfs",
"mountOptions": [],
"size": 256
},
{
"containerPath": "/tmp",
"mountOptions": [
"noexec",
"nosuid"
],
"size": 128
}
]
}
GUI表示
タスク定義、ECSダッシュボードではJSONタブで確認できました。

動作確認
タスク起動後、CloudWatch Logs に出力されたログを確認しました。
1. マウント状況の確認 (df -h)
=== tmpfs mounts verification ===
tmpfs 256M 0 256M 0% /mnt/tmpfs
tmpfs 128M 0 128M 0% /tmp
tmpfs 64M 0 64M 0% /dev
tmpfs 472M 0 472M 0% /sys/fs/cgroup
/mnt/tmpfs に 256MB、/tmp に 128MB の領域が割り当てられていることを確認できました。
2. 書き込みテスト
=== Creating test file in /mnt/tmpfs ===
test data Wed Jan 7 07:25:16 UTC 2026
=== Verification complete ===
/mnt/tmpfs 配下にファイルを作成し、cat コマンドで内容を読み取れることが確認できました。
まとめ
今回の検証により、AWS Fargate においても tmpfs が利用できることを確認できました。
これまで Fargate での一時領域はデフォルトのストレージや、EBSの増設が必要でしたが、今回のアップデートでメモリ領域を利用した高速なファイルシステムも選択肢に加わりました。
ReadonlyRootFilesystem 環境下でのセキュアな書き込み手段として tmpfs が必須であり、これまでは EC2 起動タイプを選択せざるを得なかったワークロードにおいても、今回のアップデートにより Fargate を活用できる可能性が向上しました。
なお、tmpfs の利用はタスクに割り当てられたメモリリソースを消費します。予期せぬメモリ不足は プロセスの強制終了などのトラブルを誘発するリスクがあるため、導入にあたっては十分な事前検証を実施することをお勧めします。







