Docker Course
Docker
/
Intermediate

Resource Limits

Definition

Configurations applied at runtime to strictly bound the maximum amount of CPU and Memory a specific container is allowed to consume on the host system.

Explain Like I'm New

Putting a leash on a greedy app. By default, a container will eat all the RAM it can find. If you have 5 containers, and one goes crazy, it will eat 100% of the RAM and crash the other 4. Resource limits ensure it can never use more than its fair share.

Real World Example

Running `docker run --memory="512m" --cpus="1.5" my-app`. This guarantees the application can never consume more than 512 MB of RAM or 1.5 CPU cores, protecting the rest of the server.

Common Use Cases

  • •Production stability
  • •Preventing noisy-neighbor problems

Interview Questions

basic

  • By default, does Docker limit how much RAM a container can use?

intermediate

  • What happens when a container tries to use more RAM than its defined `--memory` limit?

Flash Cards

Question

Default limits?

Click to reveal answer
Answer

No. By default, a container has no resource constraints and can use as much of the Host's resources as the Host's kernel allows.

Question

Exceed memory limit?

Click to reveal answer
Answer

The Host kernel's Out-Of-Memory (OOM) killer will intervene and instantly forcefully kill the container process to protect the system.