In this lab, you need to instate a per-container resource management. Each container needs to be configured to individually not use more than 1 CPU. Apart from that, you also need to configure each container to individually not use more than 50% of RAM.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Open Three Terminals and Three Sessions to the Lab Server
- Open three terminal sessions.
In each one, log in to the server using the credentials provided:
ssh cloud_user@<PUBLIC_IP_ADDRESS>
- Run Two Python Containers with Set Limits 50% CPU and 500M RAM
sudo docker run -it --rm --cpus="0.5" --memory=500m docker.io/python
sudo docker run -it --rm --cpus="0.5" --memory=500m docker.io/python
- Run Tests to See Your Resource Limits Take Effect
In each container, run this code and observe the resource usage with
htop
in the third terminal session:import threading def test(): while True: 1000*1000 threading.Thread(target=test).start() threading.Thread(target=test).start() threading.Thread(target=test).start() threading.Thread(target=test).start() threading.Thread(target=test).start()