Sachin helps you increase the
10-GiB storage limit with Docker
container volumes for ECS

Sachin_BLR0718

I want to increase my Docker container storage volume limit for Amazon Elastic Container Service (Amazon ECS) instances. How can I do this?

By default, Docker on ECS container instances allocates 10 gibibyte (GiB) of storage for each volume it creates. When that volume reaches the 10-GiB limit, no more data can be written, and any additional data can cause the container to crash.

You can increase the default storage allocation for Docker volumes by setting the dm.basesize storage option. After setting this value, any new images that are pulled use the new storage value. Any containers that were created or running before the change still use the previous value.

You can determine the size of your Docker container volumes with the lsblk command. In this example, each of the volumes listed under the Docker pool has 10 GiB allocated:

[ec2-user@ecs-1234abcd ~]$ sudo lsblk
NAME                                   MAJ:MIN   RM  SIZE RO TYPE MOUNTPOINT
xvda                                   202:0      0    8G  0 disk
└─xvda1                                202:1      0    8G  0 part /
xvdcz                                  202:26368  0   22G  0 disk
└─xvdcz1                               202:26369  0   22G  0 part
├─docker-docker--pool_tmeta            253:0      0   24M  0 lvm
│ └─docker-docker--pool                253:2      0 21.8G  0 lvm
│   └─docker-202:1-263201-fa61..b9ee   253:3      0   10G  0 dm
└─docker-docker--pool_tdata            253:1      0 21.8G  0 lvm└─docker-docker--pool                  253:2      0 21.8G  0 lvm└─docker-202:1-263201-fa61..b9ee       253:3      0   10G  0 dm

If you want to apply the dm.basesize setting to all your containers, you must apply the setting before the Docker service starts. On first boot, an ECS instance reads the configuration from the /etc/sysconfig/docker-storage-setup file, and then applies it to the Docker storage configuration located at /etc/sysconfig/docker-storage.

For example, you can use the following script to set the default volume allocation to 20 GiB. This script works by using a cloud boothook to add the dm.basesize option to the Docker storage configuration. This script uses the cloud-init-per tool provided by the cloud-init package to create a boothook command that runs once per instance. Cloud boothooks execute before the Docker service starts, so all your containers (including the ECS agent) will use the new setting.

#cloud-boothook
#!/bin/bash

cloud-init-per once docker_options echo 'OPTIONS="${OPTIONS} --storage-opt dm.basesize=20G"' >> /etc/sysconfig/docker

You can verify the storage size of your volumes with lsblk:

[ec2-user@ecs-1234abcd ~]$ sudo lsblk
NAME                                   MAJ:MIN   RM  SIZE RO TYPE MOUNTPOINT
xvda                                   202:0      0    8G  0 disk
└─xvda1                                202:1      0    8G  0 part /
xvdcz                                  202:26368  0   22G  0 disk
└─xvdcz1                               202:26369  0   22G  0 part
  ├─docker-docker--pool_tmeta          253:0      0   24M  0 lvm
  │ └─docker-docker--pool              253:2      0 21.8G  0 lvm
  │   └─docker-202:1-263245-6f4e..e789 253:3      0   20G  0 dm
  └─docker-docker--pool_tdata          253:1      0 21.8G  0 lvm
    └─docker-docker--pool              253:2      0 21.8G  0 lvm
      └─docker-202:1-263245-6f4e..e789 253:3      0   20G  0 dm

You should now have Docker container volumes set above the default 10-GiB limit.

Note: Running the docker info command shows a Base Device Size of 21.47 GB, because of the difference between GiB and gigabytes (GB), where 1 GiB = 1.074 GB.


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center.

Published: 2017-05-17

Updated: 2018-10-05