How can I increase my Docker container storage volume limit for Amazon ECS instances launched from Amazon Linux 1 AMIs?
Last updated: 2019-08-23
How can I increase my Docker container storage volume limit for Amazon Elastic Container Service (Amazon ECS) instances launched from Amazon Linux 1 Amazon Machine Images (AMIs)?
Short Description
By default, Docker allocates 10 gibibytes (GiB) of storage for each volume it creates on an Amazon ECS container instance. If a volume reaches the 10-GiB limit, then you can't write any more data to that volume without causing the container instance to crash.
Important: This article is applicable if you're using Amazon Linux 1 AMIs to launch container instances in your ECS cluster. Amazon Linux 2 AMIs use the Docker overlay2 storage driver, which gives you a base storage size of the space left on your disk.
Resolution
Note: The following instructions apply to instances using the devicemapper storage driver.
1. Open the Amazon ECS console.
2. In the navigation pane, choose Clusters.
3. Choose the cluster with the container instance where you want to increase the storage volume limit.
4. Choose the ECS Instances view.
5. Connect to your container instance using SSH.
6. To see the storage size of your volumes, run the following command:
sudo lsblk
You should see output similar to the following:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:1 0 8G 0 disk
├─nvme0n1p1 259:2 0 8G 0 part /
└─nvme0n1p128 259:3 0 1M 0 part
nvme1n1 259:0 0 22G 0 disk
└─nvme1n1p1 259:4 0 22G 0 part
├─docker-docker--pool_tdata 253:1 0 21.7G 0 lvm
│ └─docker-docker--pool 253:2 0 21.7G 0 lvm
│ └─docker-259:2-394380-e76dfeb812faffb7a1b5b9553c76c44b70de4e1da69fadd3b89875fee8a6c624
253:3 0 10G 0 dm /var/lib/docker/devicemapper/mnt/e76dfeb812faffb7a1b5b9553c76c44b70de4e1da69fadd3b89875fee8a6c624
└─docker-docker--pool_tmeta 253:0 0 24M 0 lvm
└─docker-docker--pool 253:2 0 21.7G 0 lvm
└─docker-259:2-394380-e76dfeb812faffb7a1b5b9553c76c44b70de4e1da69fadd3b89875fee8a6c624
253:3 0 10G 0 dm /var/lib/docker/devicemapper/mnt/e76dfeb812faffb7a1b5b9553c76c44b70de4e1da69fadd3b89875fee8a6c624
Note: The console shows that the size of the container volumes is 10G (equivalent to 10 GiB).
7. To increase the default storage allocation for Docker volumes, set the dm.basesize storage option to a value higher than 10 GiB in the Docker daemon configuration file /etc/sysconfig/docker on the container instance.
Important: After setting the dm.basesize value, any new images that are pulled by Docker use the new storage value that you set. Any containers that were created or running before you changed the value still use the previous storage value. For information on how to specify the Docker daemon configuration, see Docker Daemon.
To apply the dm.basesize option to all your containers, set the value of the option before the Docker service starts. For example, you can use the following script in the Amazon Elastic Compute Cloud (Amazon EC2) instance's user data to set the default volume allocation to 20 GiB:
#cloud-boothook
#!/bin/bash
cloud-init-per once docker_options echo 'OPTIONS="${OPTIONS} --storage-opt dm.basesize=20G"' >> /etc/sysconfig/docker
8. To verify that your new Docker container volumes are bigger than the default 10-GiB limit, run the following command:
sudo lsblk
You should see output similar to the following:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:1 0 8G 0 disk
├─nvme0n1p1 259:2 0 8G 0 part /
└─nvme0n1p128 259:3 0 1M 0 part
nvme1n1 259:0 0 22G 0 disk
└─nvme1n1p1 259:4 0 22G 0 part
├─docker-docker--pool_tdata 253:1 0 21.7G 0 lvm
│ └─docker-docker--pool 253:2 0 21.7G 0 lvm
│ └─docker-259:2-394381-13ae906f682ac57dcac9c247d0e1677f6da4f9dc35528b853a84f5dcbf570842
253:3 0 20G 0 dm /var/lib/docker/devicemapper/mnt/13ae906f682ac57dcac9c247d0e1677f6da4f9dc35528b853a84f5dcbf570842
└─docker-docker--pool_tmeta 253:0 0 24M 0 lvm
└─docker-docker--pool 253:2 0 21.7G 0 lvm
└─docker-259:2-394381-13ae906f682ac57dcac9c247d0e1677f6da4f9dc35528b853a84f5dcbf570842
253:3 0 20G 0 dm /var/lib/docker/devicemapper/mnt/13ae906f682ac57dcac9c247d0e1677f6da4f9dc35528b853a84f5dcbf570842
Related Information
Did this article help you?
Anything we could improve?
Need more help?