简体   繁体   English

ECS 任务定义是否支持卷映射语法?

[英]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 任务定义具有不可读的卷语法(带有MountPointsVolumes ),如下所示:

"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.

相关问题 我想将 EFS 挂载到 ECS,但在使用控制台为 EC2 集群创建 ECS 任务定义时没有 EFS 卷类型选项 - I want to mount EFS to ECS but I don't have EFS Volume Type option when creating ECS task definition for EC2-cluster using console 将特定 IAM 角色添加到 ECS 任务定义 - Add a specific IAM role to the ECS task definition AWS ECS 使用相同的任务定义和图像重新启动服务,无需停机 - AWS ECS restart Service with the same task definition and image with no downtime 有没有办法通过任务定义配置在 AWS ECS 中轮换日志? - Is there a way to rotate logs in AWS ECS through task definition configuration? 在 Amazon ECS 任务中指定入口点时出现问题 - Problem specifying entrypoint in Amazon ECS Task AWS ECS 集群 - 为什么任务定义需要 Memory 以及 CPU 和卷? - AWS ECS Cluster - Why does Task Definitions need Memory and CPU and Volumes? AWS EC2 EBS 卷映射 - 如何识别主机上的卷 - AWS EC2 EBS Volume mapping - how to identify volume on host Terraform - 在 ECS 容器定义中使用 SSM 参数 - Terraform - Use SSM Parameters in ECS container definition CDK:使用带有 NLB 和 ECS/Fargate 服务的 UDP 端口映射 - CDK: Use a UDP port mapping with NLB and ECS/Fargate service 在没有 ecs 服务的情况下使用 terraform 运行新任务 - Running a new task with terraform without a service in ecs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM