Per-Container Resource Management

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

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
  1. Open three terminal sessions.
  2. 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()

Additional Resources

  • Open three terminals, and establish three sessions (log in as cloud_user using the credentials provided).
  • Set CPU to 50% per container.
  • Set RAM to 500M per container.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?