CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESĪ1a4bd1c226b alpine:3.8 "sleep 3605" 2 minutes ago Up 2 minutes mymem5ĩced89c63a7e alpine:3.8 "sleep 3604" 4 minutes ago Up 4 minutes mymem4Ħ96f1cef7d57 alpine:3.8 "sleep 3603" 5 minutes ago Up 5 minutes mymem3ħ7d61012b5fd alpine:3.8 "sleep 3602" 6 minutes ago Up 6 minutes mymem2įab3faa6d23d alpine:3.8 "sleep 3600" 8 minutes ago Up 8 minutes mymem1 Shows all 5 containers running successfully. If you run top you will see no virtual RAM allocated. So this is pointless: reservations that do not reserve, and do not prevent over-reservations. docker container run -d -memory-reservation=250m -name mymem1 alpine:3.8 sleep 3600ĭocker container run -d -memory-reservation=250m -name mymem2 alpine:3.8 sleep 3602ĭocker container run -d -memory-reservation=250m -name mymem3 alpine:3.8 sleep 3603ĭocker container run -d -memory-reservation=250m -name mymem4 alpine:3.8 sleep 3604ĭocker container run -d -memory-reservation=250m -name mymem5 alpine:3.8 sleep 3605Īll containers are running even though I over-reserved RAM by 250 MB. Let's run 5 containers each reserving 250 MB of RAM. Because it is a soft limit, it does not guarantee that the container doesn't exceed the limit. If you use -memory-reservation, it must be set lower than -memory for it to take precedence. To now remove all containers, run docker rm -f $(docker ps -a -q) # remove ALL containers ––memory-reservationĪllows you to specify a soft limit smaller than -memory which is activated when Docker detects contention or low memory on the host machine. You can quickly do that (in your development environment) using: docker stop $(docker ps -a -q) #stop ALL containers So stop and prune all the containers you do not need running. That way you can easily find your tutorial container in docker ps -a output lists.
It will really help if you have only a few (preferably no) containers running. You need a very basic understanding of Docker, images, containers and using docker run and docker ps -a . 99% of this tutorial will work on any Linux distro since it mostly uses Docker commands. It would be great for your teammates if you did this tutorial directly on your computer and not on the shared development server. Some of the CPU tests hog all CPUs for 15 seconds. You will get more interesting results - for one of the tests - if your server has 4 cores or more. The CPU tests are done on a server with only 2 cores.
These resource limit tests use 20-30 MB of RAM, so even a server with only a total RAM of 512MB will do. If you don't have one already, you can follow the steps in this tutorial. You need access to an ECS server with a recent version of Docker already installed. This tutorial aims to give you practical experience of using Docker container resource limitation functionalities on an Alibaba Cloud Elastic Compute Service (ECS) instance, including: