23

I have a Lamp Docker Image. I want to start 500 containers of this image, how many RAM i need? I have tracked memory usage of each new container and it nearly the same as any other container of its image. So,if single container is using 200 MB, I can start 5 containers on Linux machine with 1 GB RAM.

My question is:

Is docker container using same memory as, for example, same Virtual Machine Image? May be I am doing something wrong in docker configuration or docker files?

Alex Shuraits
  • 432
  • 1
  • 5
  • 14
  • 1
    Same question (without answer yet): http://stackoverflow.com/questions/24702233/docker-container-and-memory-consumption?rq=1 – Thilo Jul 31 '14 at 11:34
  • 1
    See: http://blog.thestateofme.com/2014/03/12/docker-memory-profiling/ – Mark O'Connor Jul 31 '14 at 23:29
  • 2
    @AlexShuraits If you have an answer, please share the answer with the rest of us. Those of us who land here with the same question could use the help! – Mitch Kent Mar 06 '15 at 11:19

2 Answers2

15

docker stats might give you the feedback you need. https://docs.docker.com/engine/reference/commandline/stats/

Dan Tanner
  • 2,229
  • 2
  • 26
  • 39
4

I don't know the exact details of the docker internals, but the general idea is that Docker tries to reuse as much as it can. So if you start five identical containers, it should run much faster than a virtual machine, because docker should only have one instance of the base image and file system which all containers refer to. Any changes to the file system of one container will be added as a layer on top, only marking the change. The underlying image will not be changed, so the five containers can still refer to the same single base image.

The virtual machine however (i believe) will have a complete copy of the file system for each of the five instances, because it doesn't use a layered file system.

So I'm not sure how you can determine exactly how much memory you need, but this should make the concept clearer to you. You could start one container to see the 'base memory' that will be needed for one and then each new container should only add a smaller constant amount of memory and that should give you a broad idea how much you need.

SGer
  • 544
  • 4
  • 18
  • Many popular virtual machines hypervisors does support layered virtual disk by creating a machine snapshot. The snapshot records changes to the disk image rather than duplicating the entire disk. – Lie Ryan Jul 12 '15 at 02:55
  • 10
    The question is about memory (ram) not disk. – sargue Dec 25 '15 at 21:20