Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I limit resources for ffmpeg, called from a python-script, running in a docker container?

I deployed a service, that periodically does video encoding on my server; And every time it does, all other services slow down significantly. The encoding is hidden under multiple layers of abstraction. Limiting any of those layers would be fine. (e.g. limiting the docker-container would work just as well as limiting the ffmpeg-sub process.)

My Stack:

  1. VPS (ubuntu:zesty)
  2. docker-compose
  3. docker-container (ubuntu:zesty)
  4. python
  5. ffmpeg (via subprocess.check_call() in python)

What I want to limit:

  • CPU: single core
  • RAM: max 2 GB
  • HDD: max 4 GB

It would be possible to recompile ffmpeg if needed.

What would be the place to put limits in this stack?

like image 215
wotanii Avatar asked Dec 08 '25 13:12

wotanii


1 Answers

You can do it easily with your docker compose file :)

https://docs.docker.com/compose/compose-file/#resources

Just use the limits keyword and set your cpu usage !

like image 128
aparent Avatar answered Dec 11 '25 03:12

aparent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!