testcontainers-python icon indicating copy to clipboard operation
testcontainers-python copied to clipboard

Question: Can I cache a docker image

Open dbogdoll opened this issue 3 months ago • 3 comments

What are you trying to do?

I have a docker image which is based on postgres, but contains additional some (large) *.sql files in /docker-entrypoint-initdb.d/ .

When the docker container is started, it will import the sql files. This will delay the startup time until I can access the docker image for testing.

I assume that when I use testcontainers it is similiar to the call

docker run --rm

in the sense, that after the container was used, it is thrown away.

Is it possible to tell testcontainers to cache the container, so the next time I use that image the database is already initialized?

dbogdoll avatar Sep 23 '25 08:09 dbogdoll

yes, in testcontainers world this is referred to as "reusable" if you search youll see we have had several PRs about this but it is just not done yet

alexanderankin avatar Sep 23 '25 09:09 alexanderankin

Hi @alexanderankin ,

thanks for the fast response. Do you have a timeline when such a feature is integrated into testcontainers?

dbogdoll avatar Sep 23 '25 11:09 dbogdoll

no, im fairly busy at work so not sure when i will have time

On Tue, Sep 23, 2025 at 7:11 AM Dieter Bogdoll @.***> wrote:

dbogdoll left a comment (testcontainers/testcontainers-python#878) https://github.com/testcontainers/testcontainers-python/issues/878#issuecomment-3323543545

Hi @alexanderankin https://github.com/alexanderankin ,

thanks for the fast response. Do you have a timeline when such a feature is integrated into testcontainers?

— Reply to this email directly, view it on GitHub https://github.com/testcontainers/testcontainers-python/issues/878#issuecomment-3323543545, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACECGJBGNLOVFOD4YOGIWWD3UETHDAVCNFSM6AAAAACHHZMXD2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGMRTGU2DGNJUGU . You are receiving this because you were mentioned.Message ID: @.***>

alexanderankin avatar Sep 23 '25 12:09 alexanderankin