Skip to content

[Enhancement]: Use existing container (if it already exists) even if it was not created by TestContainers #1206

Open
@InspiringCode

Description

Problem

I have a container with a SQL Server that is quite resource hungry. I want to share the same docker container for my tests and for local development (F5). For local development I intent to use docker compose to start up the container. Using WithReuse doesn't work in this case, even if I manually add a reuse-id to my compose.yaml, because TestContainers always checks if a container with the reuse hash exists. In my case it tries to create a new container which results in a 409 Conflict being returned by docker.

Solution

Ideally I would be able to point to my compose.yaml file and TestContainers would just run docker compose up and wait for the container to be up and running.

But since this feature request is not really making progress, I am wondering if there is any way to achieve a similar result? Would it make sense to add an option to ignore the reuse hash?

Benefit

I some cases one really wants to share an environment between local dev and unit tests. This feature would enable this scenario.

Alternatives

One would theoretically reference the TestContainers assembly also in the production ASP.NET Core application (maybe with a "Is Debug Build" condition) and also call the ContainerBuilder there. But I am really not sure if this is a good idea?

Would you like to help contributing this enhancement?

No

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions