osrf / rocker

A tool to run docker containers with overlays and convenient options for things like GUIs etc.
Apache License 2.0
533 stars 68 forks source link

Enable memory, cpu, and other limits on the container #239

Open tfoote opened 1 year ago

tfoote commented 1 year ago

Docker allows the restriction of memory allocation from inside the container. This is valuable to make sure that containers don't potentially overflow a host's memory.

https://docs.docker.com/config/containers/resource_constraints/

Yongbeom-Kim commented 11 months ago

Hey @tfoote thanks for maintaining rocker, mind if i work on this?

tfoote commented 11 months ago

You're welcome. I'm happy to take contributions. If you have a good idea of how to implement this you can go ahead though I'd recommend a sketch of your approach first, or I'd be happy to talk with you about the best approach before you start an implementation.

Yongbeom-Kim commented 11 months ago

Sounds good,

The implementation sounds pretty simple at a technical level - entails essentially 'forwarding' the 10-or-so flags for docker run?

Can't say I'm super thrilled about writing N RockerExtension classes that basically do the same thing. I'm thinking a metaclass or a function to dynamically create these class instances would be perfect - your thoughts?

tfoote commented 11 months ago

One plugin can offer different command line options. I think that a single plugin that implements the different capacity based arguments would make sense. As long as the underlying dependencies and requirements are the same if you can share code resources that's better. I think the primary thing will be the availability of cgroups support which will likely be a shared dependency and validation check.