Docker memory limit does not show inside the container


With respect to the following article, I would like to know how to set the RAM limit for the docker container. The “free -m” command should be giving the memory limit given to the container.
Could you please let me know to achieve this.

Thank you

I have a tutorial which I didn’t test recently, so I hope it still works.

The free command will show the free memory on your entire system. What containers can have is a limit which is responsible for not allowing the process to use more than it should. That is by the way in the accepted answer on stack overflow.

Thank you for the response.
I am aware of the answer given on Stack Overflow, but this is the official Docker forum where I expect results to be shown as on a real machine. I am not satisfied with the accepted answer.
The “free -m” command, when run inside the Docker container, should show RAM as the memory given. I would like to see values similar to those on a new virtual machine with dedicated RAM limit.
Currently, the values are being taken from the host machine.
I would like to create an isolated container with a specified RAM limit, so that all commands inside the container reflect this RAM limit.
I would like to know if Docker has any plans to implement this, or if there are any other parameters in the latest version that can achieve this.

Thank you

It is not about Docker. Docker will not rewrite the free command in every operating system which was not designed to know about the limits set by control groups. Docker helps you to create a container, but will not change the filesystem. So unfotunately, the accepted answer is the right answer and we can’t give you a better answer. A container is not a virtual machine so there are some things to which we have to adapt. This is not something Docker can fix. Maybe some day there will be new commands that you can use on the host and in the containers as well, but this is not the case yet.