testcontainers-dotnet: Add missing function `WithDockerCompose`
Is your feature request related to a problem? Please describe. I love the approach of having a single container scenario for a test case but there are also scenarios where I’d like to spin up a whole set of containers and therefore use docker-compose as declaration.
Describe the solution you’d like
I’d like to spin up a set of containers by specifying a docker-compose.yml similar to the Java version https://www.testcontainers.org/modules/docker_compose/
Describe alternatives you’ve considered Not sure If there is one
- configuring the things as in the compose in code seems odd to me and leads to duplication of configuration and most of the times
docker-compose.ymlwill also be used to deploy the application under test this would be strange.
Additional context Also other library authors could benefit from such an approach, I happen to know that https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks is using compose and I think it would be great improvement on there development experience (since you don’ t have to remember starting the containers in advance 😉 )
Cheers & let me know what you think of the idea
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 54
- Comments: 31 (1 by maintainers)
Commits related to this issue
- feat: Add docker compose support (#122) — committed to nkz-soft/testcontainers-dotnet by nkz-soft 3 years ago
Thinking about the API design for this, I have a few points to raise:
Since all of the public API surface revolves around working with a single container, I propose this API for compose:
Regarding implementation - since compose is not part of the Docker Engine API, and the
docker composecommand has been part of Docker Desktop for a while now, I assume it is acceptable to use thedocker composecommand for the different compose methods (docker compose up,docker compose downetc.).Hi! How this is going? I’m really want to use it.
@HofmeisterAn
It would be nice to consider the testcontainers-java implementation. I’m not very familiar with it, but I think it is a good idea not to differentiate too much. OC, it should still be idiomatic with .NET.
I reviewed the pull request (#1082) some time ago and have a few suggestions and things I would like to discuss first (https://github.com/nkz-soft/testcontainers-dotnet/pull/1) before merging the feature and bringing it upstream.
Still working on this feature? Currently this is the only feature that still makes us use FluentDocker instead of TestContainers…
The java implementation is spinning a container to run
composecommands, I assume because they could not assumedocker-composeis installed on all machines back when it was implemented. This is where I think it makes sense to diverge from their implementation, because for a long time nowcomposeis bundled with Docker Desktop.AFAIK, no one is currently working on implementing Compose support. The related pull request is quite outdated and hasn’t seen updates in a while. IIRC, it also misses some essential features, like resolving endpoints.
If anyone’s interested in implementing Compose support or reviving the existing pull request, please feel free to jump in. It could also help to take a look at how Compose support is handled in other Testcontainers language implementations (Java, Go, Node.js) and ideally follow their approach.
This isn’t a feature I currently need for my day-to-day work, so I’m not prioritizing it. That said, if someone’s willing to sponsor the development, I’m happy to discuss and take a closer look.
Hi @HofmeisterAn I really need this feature in my project, so I think I can make it happen. I’ll keep you updated.
@SbiCA I think it would be great if you join the official Slack channel: http://slack.testcontainers.org/. Maybe, we can add the feature already in the official project? What do you think?