We can manually assign and allocate memory size or usage to a docker container usage. you can find the statistics of running docker container using the single command docker stats container_name –no-stream.
Manually Assign Memory Size:
By Default, Docker assigns the total memory of VM to the container if there is one running otherwise it distributes RAM automatically if you have more container is running on the same VM. You can manually assign memory size to the container according to your application need. I will show you how to do that.
Check Out: Manually pull Version
I have created a container of PHP without specifying the RAM manually
We will Download PHP Image
Create a Container of PHP
docker run it --name phpmem cd45c80ef616 /bin/bash
Check Out: Install Docker
As you can see by default Docker has assigned memory to phpmem container which is 0.05%. That's not total memory assign as I have run other containers on this VM too. docker stats phpmem –no-stream
Assign Memory to phpmen container manually
docker run -it –name phpmem -m 200m cd45c80ef616 /bin/bash
I have to assign 200MB to phpmem container here and now you have to check the memory of the container.
YouTube Link: Set the memory to docker container
You’re done container assign memory docker allocate usage