[英]Does ECS task definition support volume mapping syntax?
docker-compose spec support volume mapping syntax under services
, for example: docker-compose 规范支持
services
下的卷映射语法,例如:
version: '2'
volumes:
jenkins_home:
external: true
services:
jenkins:
build:
context: .
args:
DOCKER_GID: ${DOCKER_GID}
DOCKER_VERSION: ${DOCKER_VERSION}
DOCKER_COMPOSE: ${DOCKER_COMPOSE}
volumes:
- jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "8080:8080"
Following "AWSTemplateFormatVersion": "2010-09-09"
, the corresponding ECS task definition has volume syntax un-readable(with MountPoints
and Volumes
), as shown below:在
"AWSTemplateFormatVersion": "2010-09-09"
之后,相应的 ECS 任务定义具有不可读的卷语法(带有MountPoints
和Volumes
),如下所示:
"EcsTaskDefinition": {
"Type": "AWS::ECS::TaskDefinition",
"Properties": {
"ContainerDefinitions": [
{
"Name": "jenkins",
"Image": "xyzaccount/jenkins:ecs",
"Memory": 995,
"PortMappings": [ { "ContainerPort": 8080, "HostPort": 8080 } ],
"MountPoints": [
{
"SourceVolume": "docker",
"ContainerPath": "/var/run/docker.sock"
},
{
"SourceVolume": "jenkins_home",
"ContainerPath": "/var/jenkins_home"
}
]
}
],
"Volumes": [
{
"Name": "jenkins_home",
"Host": { "SourcePath": "/ecs/jenkins_home" }
},
{
"Name": "docker",
"Host": { "SourcePath": "/var/run/docker.sock" }
}
]
}
}
Does ECS task definition syntax of CloudFormation (now) support volume mapping syntax? CloudFormation(现在)的 ECS 任务定义语法是否支持卷映射语法? similar to docker-compose....
类似于 docker-compose....
Yes, of course, ECS support docker socket mounting, but the syntax is bit different.是的,当然,ECS 支持 docker socket 挂载,但语法有点不同。 Add
DOCKER_HOST
environment variable in the task definition and source path should start with //
.在任务定义中添加
DOCKER_HOST
环境变量,源码路径以//
开头。
"volumes": [
{
"name": "docker",
"host": {
"sourcePath": "//var/run/docker.sock"
}
}
]
The //
worked in case of AWS ecs. //
在 AWS ecs 的情况下有效。
Also, you need to add DOCKER_HOST
environment variable in your task definition.此外,您需要在任务定义中添加
DOCKER_HOST
环境变量。
"environment": [
{
"name": "DOCKER_HOST",
"value": "unix:///var/run/docker.sock"
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.