Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Increase docker container size easily with these simple steps

by | Dec 14, 2016

Docker containers can be used for multiple purposes such as application deployment or service hosting. The number of containers that can be hosted in a machine depends on the total disk space available.

For cost-effective hosting purposes, it is often required to restrict the individual docker container size. This limitation is also useful to ensure that a single user do not use up the entire disk space in the host machine.

Setup and manage your Docker system

GET IN TOUCH WITH THE DOCKER EXPERTS NOW!

A sneak-peak into Docker storage drivers

The feature to limit container size is only supported in Devicemapper storage and not by other storage drivers of Docker. In Docker, the storage drivers are responsible for managing the container’s filesystem.

The storage drivers supported by Docker for its containers are Devicemapper, Overlay, AUFS, BTRFS and ZFS. You can choose the driver during Docker installation and change it later on, if required.

This storage driver is applicable for all the containers in that host. To know the storage driver used for your Docker, you can use the command ‘docker info’.

 

Docker container size with Devicemapper storage driver

Docker containers with Devicemapper storage driver

 

[ Are your spending too much time managing your Docker containers? Our Docker experts take care of your infrastructure and ensure its smooth functioning. ]

What are the default Docker container size limits?

In Docker, there is a storage pool where the Docker containers are created. While using Defaultmapper storage, the storage pool size that is created is of default size 100 GB, as shown in the ‘Data Space Total‘ field in ‘docker info’.

Likewise, there is a default limit of 10 GB size set for the containers. This is the maximum size up to which a container can grow, and is defined by the parameter ‘Base Device Size‘. Increasing the container size limit is possible, as long as its within the pool limit.

When this default limit for docker container size is increased in Docker, it will impact the size all newly created containers. It is also possible to increase the storage pool size to above 100GB.

Here, we’ll see how to configure devicemapper storage option to set the container size and storage pool limits in Docker.

Increase default limits for docker container size and storage pool

Over time, it is probable that the disk space allotted to your docker containers is not sufficient for your business purposes. You may also want to increase the size of the storage pool so that you can create more containers for your growing business needs.

To increase the docker container size limits, the first requirement is to have enough disk space in the host machine.

Suppose you have enough space in /var partition and you need to increase storage pool size and docker container size limit. Here’s how to do it:

How to increase Docker storage pool size limit

To increase the overall storage pool size of Docker machine, follow these steps:

1. Backup all the existing Docker containers and images that you need and copy them to an external location.

2. Stop the Docker daemon.

3. Clear the current Docker default directory, which will delete all existing containers and images.

4. Create the storage directory “/var/lib/docker/devicemapper/devicemapper”.

5. Create the storage pool with your required new size, say 300 GB using the command:

dd if=/dev/zero of=/var/lib/docker/devicemapper/devicemapper/data bs=1G count=0 seek=300

6. Restart the Docker daemon with Devicemapper storage driver support.

7. Confirm the new storage pool size from the ‘Data Space Total’ in ‘docker info’.

How to increase Docker container size limit

The minimum size of docker containers is 10 GB and its not possible to decrease it further. But you can increase the docker container size from 10 GB it to a higher value, say 20 GB, with these steps:

1. Stop the Docker daemon after taking backup of existing containers and images.

2. Reset the Docker default directory.

3. Start Docker service with the parameter ‘dm.basesize’ set for the new value for Docker container size limit.

dockerd --storage-opt dm.basesize=20G

The newly created containers will now have their size limits set to 20 GB.

[ Running a Docker infrastructure doesn’t have to be hard, or costly. Get world class Docker management services at affordable pricing. ]

Change Docker default directory to expand space

The default docker directory is ‘/var/lib/docker’. This is the directory where the storage pool is located. The pool size is limited by the size of the ‘/var’ partition.

 

Docker container size - default directory setting

Docker default directory

 

In situations where the /var partition gets filled up as more and more containers are created, the Docker storage may soon run out of space.

It is usually difficult to re-partition the host machine and allocate more disk to /var, which makes it impossible to assign more space to the storage pool.

But, there is a workaround by changing this directory to another partition with enough space. To know how to do it, check out our post ‘How to change Docker directory’.

Clear Docker cache to save disk space

Usually the docker container size expansion is required in scenarios where the disk usage is high and there isn’t enough space for hosting an application or a service in it.

But changing the size limits and directory settings of existing containers involves data loss. The size limit changes will affect all the containers that would be created in that host machine.

Also, in some Docker machines, there may not be enough disk space available in the host to increase the limits or add a new default directory.

So, in all these cases, increasing docker container size is not a solution for the disk space issue. Instead, a practically feasible solution we implement is removing the unwanted images and containers, which helps save the disk space allotted to them.

Clearing the Docker cache also helps to save some disk space. To know how we clear cache and remove dangling images in Docker, check out our post ‘How to clear Docker cache and save disk space‘.

[ Use your time to build your business. We’ll take care of your customers. Hire Our Docker Support Specialists at affordable pricing. ]

In short..

Today we saw how to increase Docker container size and storage pool default limits. If there is any valuable data, always take proper backups of containers before making any changes.

If the host machine itself is running out of disk space, then the only option is to resize the partition and then set up a new Docker system and migrate the containers.

Straightaway increasing the docker container size limits for a disk space issue is not recommended, as it can lead to wastage of disk space. So, try clearing the cache and unwanted containers, before changing the limits.

Proper resource planning is very important to save costs without compromising the business needs. If you’d like to know how to manage your Docker infrastructure to get the best out of them for your business, we’d be happy to talk to you.

 

Do you provide Docker hosting services?

Wish you had more time to focus on your business? Let us help you.

Our engineers will assist you to setup, monitor and manage your Docker infrastructure 24/7.

GET IN TOUCH WITH THE EXPERTS NOW!

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF