0

My goal is to define container definitions("ContainerDefinitions") with appropriate memory size needed in RAM to launch the docker container.

For example, below code snippet for jenkins container(app) gets launched in 500 MB RAM and it works fine, dont know why, given docker image disk size of 1.64GB. here is the Dockerfile.

"EcsTaskDefinition": {
            "Type": "AWS::ECS::TaskDefinition",
            "Properties": {
                "ContainerDefinitions": [
                    {
                        "Name": "jenkins",
                        "Image": "somedockeraccount/jenkins:ecs",
                        "Memory": 500,
                        "PortMappings": [ { "ContainerPort": 8080, "HostPort": 8080 } ],

Inspecting a running system in my ubuntu laptop

Below commands are giving disk space of that jenkins image as 1.64GB, which may not be the actual size of docker image:

$ docker image ls
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
somedockeraccount/jenkins   ecs                 d9d23cc59412        38 hours ago        1.64GB
$ docker image inspect somedockeraccount/jenkins:ecs | grep -i size 
        "Size": 1640601180,
        "VirtualSize": 1640601180,

Docker image is using overlay2 filesystem(/var/lib/docker/overlay2/)

docker ps -q | xargs docker inspect also shows overlay2 filesystem

Below metadata of docker container on testing locally does not give any clue of RAM size requirement:

$ docker ps -q | xargs docker inspect | grep -i memory
            "Memory": 0,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,

In Linux VM world, we generally do not restrct any C/C++/Java app to fit in specific virtual address space boundaries. It is generally 4 GB virtual address apce for 32 bit app. vmstat command also gives clear picture on RAM usage and other resources, by any application process(pid) in Guest OS, as shown below:

enter image description here


Question:

1) How to find the amount of resources(RAM memory etc..) needed to launch a docker container(say this Dockerfile/app), in docker host? Because "ContainerDefinitions" requires this attribute "Memory" as shown above..

This helps me picking specific EC2 instance type(t2.micro or whatever) in production, based on memory size

2)

Reference does not answer this below question...

Am still unclear, how a RAM size of "Memory":500 MB able to launch docker container for docker image of 1.65 GB (disk space size)?

  • @CharlesDuffy Migrated the question... – overexchange Nov 30 '19 at 20:46
  • It looks as if you are confusing the size of the Docker image with the amount of RAM it will need to execute. The host machine will not load the image into RAM. – Kusalananda Nov 30 '19 at 21:01
  • It is like needing 30GB of RAM to run IOS because it has 30GB on disk (which is obviously not the case). – Matus Dubrava Nov 30 '19 at 21:02
  • @Kusalananda Am confused because this reference does not answer my second question – overexchange Nov 30 '19 at 21:04
  • @overexchange It does not answer your second question because it's not the same question. Just like a virtual machine's disk does not need to be loaded into the RAM of the host machine, a container's disk does not need to be loaded into RAM. – Kusalananda Nov 30 '19 at 21:10
0

Think of a container as a base image plus a layer that can hold file changes but is lost when the container is removed. Within that container one or more processes run that consume memory and CPU. In the example you gave, Jenkins has a minimum amount of memory it needs to run according to the requirements page [1]. One specific part is of crucial importance to your question:

The amount of memory Jenkins needs is largely dependent on many factors, which is why the RAM allotted for it can range from 200 MB for a small installation to 70+ GB for a single and massive Jenkins master. However, you should be able to estimate the RAM required based on your project build needs.

This is generally true for anything you want to run in a container. The process still needs memory to function, but the RAM/CPU footprint required should be less than a virtual machine because you're not trying to run a full OS within the container, only the processes associated with the container entry point.

[1] https://jenkins.io/doc/book/hardware-recommendations/

  • I have mentioned your first point in query – overexchange Nov 30 '19 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.