Resizing Docker shm-size
- arjun5792
- Oct 25, 2022
- 2 min read
Set the Docker shm-size performance parameter appropriately to promote communication between processes. With our Docker Support Service, we at Skynats can assist you with your Docker shm problems.
Docker shm-size
The shared memory allotted to a docker container is referred to as the "docker shm size." A Docker /dev/shm filesystem uses RAM to store files and is used for temporary file storage. Additionally, it makes interprocess communication easier (IPC). However, having a shared memory device is optional.
The shared memory device's size is specified by the -shm-size=" " parameter. It has the following format: number>unit
>. In this scenario, the number must be greater than 0. The unit is optional and can be b (bytes), k (kilobytes), m (megabytes), or g (gigabytes). If no unit is specified, the system uses bytes. The system uses 64m if we ignore the size entirely.
How to change Docker shm-size?
Docker containers have 64 MB of memory by default. The Docker shm-size can now be changed by executing the following commands.
Start by launching the Ubuntu container.
docker run --rm -it --name ubuntu ubuntu
Using Docker inspect, verify the shm-size.
docker inspect ubuntu | grep -i shm
"ShmSize": 67108864,
//The default is precisely 64 MB.
Run the command below to modify the Docker shm-size:
docker run --rm -it --name ubuntu --shm-size=2gb ubuntu
Finally, execute the following command to verify the change:
docker inspect ubuntu | grep -i shm
"ShmSize": 2147483648,
//Now the size is changed to 2 GB.
The container is given a /dev/shm that is distinct from the host's. We can also use the command ls -l /dev/shm to confirm it. "Total 0" will be the outcome.
Conclusion
With the help of the instructions mentioned in the post, resizing the Docker shm size is now possible. Last but not least, we provided the straightforward steps our tech team used to modify the Docker shm-size.
Comments