Skip to content
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

Allow reuse of containers needed by DevServices (opt-in) #25367

Merged
merged 2 commits into from
May 5, 2022

Conversation

Sanne
Copy link
Member

@Sanne Sanne commented May 4, 2022

Fixes #25365

To try it out, use any demo which is needing a container which is relatively slow to start; for example Oracle database, which will take ~ 1 minute to start.
Run it twice (not in dev-mode), the second time it will need to start the container again.

If you have a file named .testcontainers.properties in your ~ and add:
testcontainers.reuse.enable=true

you'll notice the container stays alive for some longer time, and the second run is allowed to reuse the same container instance.

I'm sure this workflow isn't for everyone, but since one has to explicitly opt-in I think it's very nice.

Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@gastaldi
Copy link
Contributor

gastaldi commented May 4, 2022

If you have a file named .testcontainers.properties in your ~ and add: testcontainers.reuse.enable=true

Can we have this documented somewhere before merging this PR?

@Sanne
Copy link
Member Author

Sanne commented May 4, 2022

If you have a file named .testcontainers.properties in your ~ and add: testcontainers.reuse.enable=true

Can we have this documented somewhere before merging this PR?

Where would you look for it? It's a bit specific to Testcontainers

@gastaldi
Copy link
Contributor

gastaldi commented May 4, 2022

@Sanne
Copy link
Member Author

Sanne commented May 4, 2022

thanks for the hint @gastaldi , added a couple paragraphs.

At this time it's limited to containers used for relational databases so I've only mentioned it in that section; we can expand on this later if people find it useful.

@GregJohnStewart
Copy link
Contributor

Would we want to wrap the config for this into the devservices config, rather than need an additional file to config with?

@stuartwdouglas
Copy link
Member

+1 from me. I had looked at re-use before but I thought it was just for re-using containers inside the same JVM, I did not realize the container could survive JVM exit.

Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@Sanne
Copy link
Member Author

Sanne commented May 5, 2022

Would we want to wrap the config for this into the devservices config, rather than need an additional file to config with?

I have wondered the same, but Testcontainers doesn't expose this. We would need to either hot-patch it or to overwrite the user's configuration file - not nice.

And it's a rather advanced option of Testcontainers, I think for now I'd rather have the users aware that it's Testcontainers stuff and that they refer their documentation + configuration; it might have other implications and there's more tuning options that I haven't mentioned here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow reuse of containers started via DevServices
5 participants