如何删除Amazon Elastic Container Service-ECS中的现有Docker卷(数据卷)?

时间:2018-12-24 14:24:23

标签: amazon-web-services docker amazon-ecs docker-volume

我目前在Amazon ECS中有一个Nginx Docker映像。我需要通过certbot重新颁发SSL证书,并且需要删除旧证书。如何删除该卷?我当前将使用新卷而不是旧卷(附加“ v2”后缀)。

这是我的任务定义的一部分(如上所述,我不得不将其重命名为v2):

"mountPoints": [
                {
                    "sourceVolume": "nginx-certbot-v2",
                    "containerPath": "/etc/letsencrypt",
                    "readOnly": false
                },
                {
                    "sourceVolume": "nginx-acme-webroot-v2",
                    "containerPath": "/var/acme-webroot",
                    "readOnly": false
                },
                {
                    "sourceVolume": "nginx-dhparam-v2",
                    "containerPath": "/etc/nginx/dhparam",
                    "readOnly": false
                }
            ],

这是音量的定义:

"volumes": [
      {
          "name": "nginx-certbot-v2",
          "dockerVolumeConfiguration": {
              "scope": "shared",
              "autoprovision": true,
              "driver": "local"
          }
      },
      {
          "name": "nginx-acme-webroot-v2",
          "dockerVolumeConfiguration": {
              "scope": "shared",
              "autoprovision": true,
              "driver": "local"
          }
      },
      {
          "name": "nginx-dhparam-v2",
          "dockerVolumeConfiguration": {
              "scope": "shared",
              "autoprovision": true,
              "driver": "local"
          }
      }
  ]

我是否有可能在没有“ v2”的情况下找回卷?

1 个答案:

答案 0 :(得分:1)

将Docker卷的范围定义为任务而不是共享,它将在任务停止后自动删除。

"volumes": [
{
    "name": "scratch",
    "dockerVolumeConfiguration" : {
        "scope": "task",
        "autoprovision": true,
        "driver": "local",
        "labels": {
            "scratch": "space"
        }
    }
}

]

请参阅此链接以获取更多信息

ECS docker volume reference