-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to set the memory capacity for a GenericContainer
?
#298
Comments
So you want to set a memory limit? AFAIK testcontainers doesn't expose an API for this yet. I also only found a fitting API in docker-java inside the UpdateContainerCmd class, not inside |
+1 |
@benhinssen could you please give some context for use cases for which this feature is needed? |
It looks like it's there on CreateContainerCmd. It's worth supporting, but we might be opening a can of worms if we add this directly to the GenericContainer API. Perhaps the more maintainable approach is to use some upcoming preconfig/postconfig hooks that @bsideup was working on that allow you to modify the CreateContainerCmd directly before it's created. How does that sound? |
+1 from me on hooks :) Something like: new GenericContainer(...)
.withCreateCmdHook(cmd -> cmd.withMemory(1024)) (naming is not final) |
@kiview of course. At this moment we are having some problems that our build server is running out of resources when running multiple builds simultaneously. The obvious way to prevent this from happening is to limit the max resources that can be used by each docker container. |
See #301 |
@macks22 @benhinssen since 1.2.0 is out, does https://www.testcontainers.org/usage/options.html#customizing-the-container sound good enough for you? :) |
@bsideup yes this meets the need; thank you! @benhinssen feel free to close if your use case is satisfied. |
Looks good and fits the requirement! Thanks! |
Great, thanks @benhinssen, @macks22! I'll close the ticket then 😄 |
I have the following
GenericContainer
:Normally, I would specify the memory using the
-m
flag to docker. How can I do this with this container?The text was updated successfully, but these errors were encountered: