Linux Labs

Containers: Docker and compose / Stage 10 of 11

Limits, OOMKilled and the user in a container

Not running Starting usually ~20 s
Leave the lesson

Step 3 of 9 · on a machine · 4 min

How much a container takes

The memory ceiling is visible on a running container too. The machine has three containers created with different options.

Exercise · look

Compare three containers

Look at the list of running containers, then at a single snapshot of their usage in docker stats.

First, predict

cron was created without the --memory option. What will docker stats show for it in the LIMIT column?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in

docker stats is a usage table for each running container: the CPU share CPU %, the memory MEM USAGE and the ceiling LIMIT. Without options it keeps updating on screen until you press Ctrl+C; --no-stream prints a single snapshot.

api's ceiling is 64MiB, from its --memory 64m. cron has no limit, and its LIMIT says 458.2MiB — all of the machine's memory. Such a container can take memory the other services need. When memory runs out on the whole machine, the OOM killer picks its victim among all processes — it may be the database or sshd.

Ubuntu 24.04
Loading…