简体   繁体   中英

How can I delete an existing Docker Volume (Data Volume) in Amazon Elastic Container Service - ECS?

I currently have an Nginx Docker image in Amazon ECS. I need to re-issue the SSL certificates via certbot, and I need to delete the old ones. How can I delete the volume? I'm currently going to use new volumes instead of the old ones (appending a "v2" suffix).

Here's part of my task definition (As stated above, I had to rebrand them as 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
                }
            ],

Here's the volume definition:

"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"
          }
      }
  ]

Are there any possibilities for me to get back the volumes without the "v2"?

Define the scope of your docker volume as task instead of shared it will be removed automatically after the task is stopped.

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

]

refer to this link for more information

ECS docker volume reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM