docker - 如何允许具有只读根文件系统的容器写入 tmpfs-volume?
问题描述
我有以下问题:
我的 nginx 容器从只读根文件系统开始,我已经配置了两个 tmpfs 挂载:/var/run 和 /var/cache/nginx,就像那里描述的那样:https ://hub.docker.com/_/nginx
启动时 nginx 抛出此错误并且容器停止: 2021/08/26 06:31:16 [emerg] 1#1: mkdir() "/var/cache/nginx/client_temp" failed (30: Read-only file system )
这是我的 ecs 任务配置:
{
"name": "nginx",
"essential": false,
"readonlyRootFilesystem": true,
"healthCheck": {
"command": [
"CMD-SHELL",
"curl --fail 127.0.0.1 || exit 1"
],
"interval": 30,
"timeout": 2,
"retries": 3
},
"memory": 256,
"image": "###########.dkr.ecr.eu-central-1.amazonaws.com/nginx:${NGINX_VER}",
"dockerLabels":
{
"Name": "nginx",
"Component": "sidecar-prometheus",
"App-Version": "${NGINX_VER}"
},
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${LOG_GROUP_NAME}",
"awslogs-region": "eu-central-1",
"awslogs-stream-prefix": "${LOG_GROUP_NAME}"
}
},
"portMappings": [
{
"containerPort": 10000,
"hostPort": 10000,
"protocol": "tcp"
}
],
"mountPoints": [
{
"readOnly": false,
"containerPath": "/config",
"sourceVolume": "VolumeConfig"
}
],
"tmpfs": {
"containerPath": "/var/run",
"size": "50",
"mountOptions": "rw"
},
"tmpfs": {
"containerPath": "/var/cache/nginx",
"size": "50",
"mountOptions": "rw"
},
我怎样才能使 /var/cache/nginx 挂载 rw ?
非常感谢您的帮助!
解决方案
看着文档,tmpfs
接受Array of Tmpfs objects
。
你似乎传递tmpfs
了两次,而不是传递一个数组。正确传递数组应该可以工作:
"tmpfs": [
{
"containerPath": "/var/run",
"size": "50",
"mountOptions": "rw"
},
{
"containerPath": "/var/cache/nginx",
"size": "50",
"mountOptions": "rw"
}
]
推荐阅读
- javascript - 需要在页面加载时保持切换处于活动状态,并在页面加载时将其隐藏
- dart - 有没有更好的方法通过在 Dart 中添加 2 个对象键来创建对象?
- javascript - 无法拼接对象数组中的项目
- vue.js - 如何将 Google、Facebook 和 Linkedin 登录与 nuxt js 集成
- git - 对开发人员团队的 Codespaces 设置的基数感到困惑
- c# - 如何在 C# Discord Bot 上使用 JSON API
- javascript - 测试 express.js API 的最佳方法是什么
- flutter - 我如何将 texformfield 的值传递给颤动的列表
- ios - Xamarin Forms:由于 MediaElement 功能,ios 平台中的本机崩溃报告
- python - 正则表达式匹配返回几个捕获块