I am wondering why this is needed from a VM configured with Memcached?
Security:. If someone violates memcached and file system trojans, it does not matter - the file system is discarded when a new memchached starts.
Insulation:. You can tightly restrict each container so that it does not use too much RAM.
Standardization: Currently, each application / database / cache / load balancer should record what to install, what to configure, and what to run. There is no standard (and no shortage of tools such as puppet, chef, etc.). But these tools are very complex, not OS independent (despite their requirements) and carry the same complexity from development to deployment.
With docker, all this is just a container starting with run BLAH . If your application has 5 levels, you have only 5 containers to run, with a little orchestration on top. Developers never need to "look into the container" if they do not develop at this level.
Resources: You can deploy 1000 docker containers on a regular PC, but you will have problems starting 100 virtual machines. The limit is both the processor and the RAM. Dock containers are simply processes in an "enhanced" chroot. There are many background processes on the virtual machine (cron, logrotation, syslog, etc.), but there are additional no for dockers.
I guess it would be pointless to have more than one memcached docker container running under the same host
It depends. There are times when you want to split your RAM into packages rather than global. (for example, imagine if you want to spend 20% of the cache for caching users and 40% of the cache for caching files, etc.).
In addition, most fragments schemes are difficult to expand, so people often start with many βvirtualβ fragments, and then expand to physical boxes when necessary. Thus, you can start with your application, knowing about 20 memcached instances (selected based on the identifier of the object). First, all 20 work on the same physical server. But later you divided them into 2 servers (10/10), then into 5 servers (4/4/4/4) and, finally, into 20 physical servers (1 memory each). This way you can scale the 20x application by simply moving the virtual machines and not changing your application.
the only real advantage is the advantage of the speed of the "rotation" of the memcached stack in the docker container and Memcached through the virtual machine. Is it correct?
No, this is just a small advantage. see above.
Also, how to set the memory that memcached will use in the docker container?
In the docker run just use -m .
How will this work if there are two or more Memcached docker containers under the same host? (I again assume that two or more does not make sense).
Same. If you did not set a memory limit, that would be exactly like starting 2 memcached processes on the host. (If someone fills the memory, both will go out of memory.)