I want to increase my Docker container storage volume limit for 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 of your containers, you must apply the setting before the Docker service first starts. On first boot, an ECS instance reads the configuration from the /etc/sysconfig/docker-storage-setup file and applies it to the Docker storage configuration located at /etc/sysconig/docker-storage.

For example, you can use the following script to set the default volume allocation to 20 GiB. This 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 of 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-263201-fa61...b9ee  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-263201-fa61...b9ee    253:3       0   20G    0   dm

Note: Running the docker info command shows a Base Device Size of 21.47 GB because of the difference between GiB and gigabytes (GB); 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