Bobcares

Docker shm-size | How To Resize It?

by | Oct 24, 2022

Facilitate the communication between processes by properly setting the performance parameter, Docker shm-size. We at Bobcares can help you with your Docker shm difficulties with our Docker Hosting Support Service.

What is Docker shm-size?

Docker shm size refers to the amount of shared memory allotted to a docker container. A Docker /dev/shm is a temporary file storage filesystem using RAM for storing files. It also facilitates inter-process communication (IPC). However, it’s optional to have a shared memory device.

The parameter, –shm-size=” ” describes the size of the shared memory device. It is in the format <number><unit
>. The number in this case must be larger than 0. The unit might be b (bytes), k (kilobytes), m (megabytes), or g (gigabytes) and is optional. The system uses bytes if the unit is left out. If we completely ignore the size, the system uses 64m.

How to change Docker shm-size?

The Docker container’s shared memory (shm-size) can be modified to suit our application’s requirements. By default, the shm-size is set to 64 MB, but we can change it to a different value as needed.

  1. To begin with, launch an Ubuntu container:

    docker run --rm -it --name ubuntu ubuntu

  2. We can confirm the default shm-size with this command:

    docker inspect ubuntu | grep -i shm

    This will output the current shm-size, which is typically set to 64 MB:

  3. To change the shm-size, use the –shm-size option when running the container.

    For example, we can set the shm-size to 2 GB as seen here:

    docker run --rm -it --name ubuntu --shm-size=2gb ubuntu

  4. Then, confirm that the shm-size has been changed, you can use this command:

    docker inspect ubuntu | grep -i shm

    This should now output the new shm-size of 2 GB:

    “ShmSize”: 2147483648,

  5. Additionally, we can verify that the container has a unique /dev/shm by running the following command:

    ls -l /dev/shm

    This will output total 0, indicating that the container has its own separate shared memory space, distinct from the host’s.

In summary, the article explains how to properly set the Docker shm-size parameter to control the amount of shared memory allocated to a container, which is important for applications like databases that rely heavily on shared memory for inter-process communication.

[Searching for an answer to another question? We can help you 24/7.]

Conclusion

Resizing the shm size is now possible with the use of the post’s mentioned instructions. Finally, we offered the simple procedures our Tech team used to change the Docker shm-size.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

4 Comments

  1. Neeraj

    great post. thanks. just what I was looking for. thanks.

    Reply
    • Hiba Razak

      Hello Neeraj,
      Thanks for the feedback.

      Reply
  2. CoccoDev

    The command gives me this error: The container name “mycontainer” is already in use by container “abcdefgh12345”. You have to remove (or rename) that container to be able to reuse that name. :/

    Reply
    • Hiba Razak

      Hello,
      Please contact our support team via live chat(click on the icon at right-bottom).

      Reply

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.

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

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

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