dotnet / Docker.DotNet

:whale: .NET (C#) Client Library for Docker API
https://www.nuget.org/packages/Docker.DotNet/
MIT License
2.23k stars 381 forks source link

Question: how to use Docker.DotNet with docker-compose #638

Closed syberside closed 1 year ago

syberside commented 1 year ago

Hi!

I've deleted default template content because it's not relevant to my question. Hope this is okey :)

The library seems very useful for integration testing on projects with infrastructure deps hosted in docker. However I'm struggling with the way to use this library with docker-compose. My first thought was to duplicate configuration from compose to c# test, but this will introduce duplication. Second thought was to parse yaml and transform it to docker commands by code. But this seem a little bit odd. Is there some way to use Docker.DotNet with docker-compose in convenient way?

HofmeisterAn commented 1 year ago

I think that including support for Docker Compose is beyond the intended scope of Docker.DotNet. Docker.DotNet serves as a client for the Docker Engine API.

The library seems very useful for integration testing on projects with infrastructure deps hosted in docker.

There exists an open-source project named Testcontainers that specifically does that. The .NET implementation is built on top of Docker.DotNet.

Second thought was to parse yaml and transform it to docker commands by code. But this seem a little bit odd.

This is similar to what the Testcontainers for Java does. It has a Docker Compose module. However, this module is currently not included in the .NET implementation. Adding it would definitely be a great feature.

syberside commented 1 year ago

@HofmeisterAn thanks for response.

Testcontainers seems interesting. May be I'll try to port compose java module some day :D