-
Notifications
You must be signed in to change notification settings - Fork 375
feat: support with_copy_to#976
Conversation
Solves #665
rhoban13
commented
Mar 11, 2026
I think this is the same use case as #852
Oh yeah. Look at that. You are absolutely right. I haven't seen yours.
I guess the only difference is, that mine is copying the files before the container gets started, to make files available at start time, isn't it?
0c87901 to
88acf8f
Compare
alexanderankin
commented
Apr 1, 2026
still needed after #852 ?
guenhter
commented
Apr 1, 2026
I'll rebase and bring in the modified startup handling in order to be able to copy in files before the container is started.
Tranquility2
commented
Apr 1, 2026
Hi, just a quick checkup, is this still relevant now that we have container.copy_into_container(my_file, "/tmp/my_file.txt") ready?
At the moment, the following tests is not possible:
def test_copy_into_startup_file(transferable: Transferable): destination_in_container = "/tmp/my_file" container = DockerContainer("bash", command=f"cat {destination_in_container}") container.with_copy_into_container(transferable, destination_in_container) with container: exit_code = container._container.wait() stdout, _ = container.get_logs() assert exit_code["StatusCode"] == 0 assert stdout.decode() == "hello world"
This is what I ment with
I guess the only difference is, that mine is copying the files before the container gets started, to make files available at start time, isn't it?
Who it works now: when the container is started, the file is copied into the started container.
How is should be: the container should be created, then the file is copied into and then the container gets started having all the files available at start time.
This is often crucial like when you want to copy in a config file which is used by the entrypoint script or even more: if you copy in the actual entrypoint script the container should start with.
88acf8f to
8f32d9b
Compare
guenhter
commented
Apr 2, 2026
@rhoban13 I've updated this PR based on your changes. Maybe you can have a quick glimpse if it seems ok for you.
rhoban13
commented
Apr 2, 2026
Ah - I see the use case, I suspect this will be a much larger piece of work.
You're introducing here the notion of createing a container prior to starting it, which I think is a good idea, but feels like a different piece or work. I believe @alexanderankin has talked about the need do this, but quick glance I'm not seeing any issues tracking that work.
2 immediate workarounds I can think of would be:
- Copy the files into an image and pass that image into the Container
- Mount instead of copying
alexanderankin
commented
Apr 2, 2026
imo its ok if we start implementing create before start here (this is not a soc2 workplace where each PR needs an approved ticket), but the wait method idk if we want that at all, and image pulling would probably need a follow up to account for things like private mirrors, image pull policy (never, ifabsent, always), etc. other than that it looks ok, right?
alexanderankin
commented
Apr 2, 2026
ok so lets centralize the discussion about creating before starting #997 because maybe there are some nuances to discuss although im not sure what they are, my approach was going to be to release some release candidates before the next minor version to test this stuff out
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@ ## main #976 +/- ## ========================================== - Coverage 83.05% 82.97% -0.09% ========================================== Files 16 16 Lines 1700 1721 +21 Branches 186 189 +3 ========================================== + Hits 1412 1428 +16 - Misses 234 236 +2 - Partials 54 57 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
59ec1ce
into
testcontainers:main
🤖 I have created a release *beep* *boop* --- ## [4.15.0-rc2](testcontainers-v4.15.0-rc.1...testcontainers-v4.15.0-rc2) (2026年04月30日) ### Features * **core:** support TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX ([#961](#961)) ([be9a0a6](be9a0a6)) * **mongodb:** Add Atlas Local for MongoDb ([#873](#873)) ([73aeb43](73aeb43)) * support with_copy_to ([#976](#976)) ([59ec1ce](59ec1ce)) * **valkey:** add Valkey module ([#947](#947)) ([fc09dc1](fc09dc1)) ### Bug Fixes * **azurite:** use `HttpWaitStrategy` instead of deprecated `wait_container_is_ready` ([#1003](#1003)) ([9fe6b07](9fe6b07)), closes [#874](#874) * fix pr [#961](#961) ([#1011](#1011)) ([8eff908](8eff908)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: David Ankin <daveankin@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
This PR supports copying files into the container before startup time:
To support this, I had to change how the container is started:
runis not longer used, but insteadcreateandstartare used now, in order to be able to make thecopybefore the container is actually running.Inspired by testcontainers/testcontainers-rs#730 where I did exactly the same feature for the rust implementation of testcontainers :)
No tests are failing