Help Center> Cloud Container Engine> FAQ> Reference> How Do I Expand the Storage Capacity of a Container?

How Do I Expand the Storage Capacity of a Container?

Scenario

The default storage size of a container is 10 GB. If a large volume of data is generated in the container, expand the capacity using the method described in this topic.

Resizing a Docker Container

  1. Log in to the corresponding node as user root and edit the daemon.json file.

    vi /etc/docker/daemon.json

    Add dm.basesize=15G to the file. 15G indicates the storage size of the container and is used as an example here.

    {
         "storage-driver": "devicemapper",
         "storage-opts": [
         "dm.thinpooldev=/dev/mapper/vgpaas-thinpool",
         "dm.use_deferred_removal=true",
         "dm.use_deferred_deletion=true",
         "dm.basesize=15G"
         ]
    }

  2. Restart the Docker container.

    systemctl restart docker

  3. Delete the image from the node.

    The space allocated to the container is determined based on the configuration when the image is downloaded. Therefore, if you want to create a container with a new storage capacity, delete the image (if the image has dependent layers, they also need to be deleted).

  4. Create a workload. For details, see Creating a Deployment.
  5. Log in to the node in 1, restart the node, and run the following command to access the container and check whether the container capacity has been expanded:

    docker exec -it container_id /bin/sh or kubectl exec -it container_id /bin/sh

    df -h