Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing function WithDockerCompose #122

Open
SbiCA opened this issue Aug 12, 2019 · 29 comments · May be fixed by #1082
Open

Add missing function WithDockerCompose #122

SbiCA opened this issue Aug 12, 2019 · 29 comments · May be fixed by #1082
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@SbiCA
Copy link

SbiCA commented Aug 12, 2019

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.yml will 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

@HofmeisterAn
Copy link
Collaborator

Hi @SbiCA, a great feature for sure. I think docker compose supports a lot of different use cases and is a very important feature. I had it on my list right from the start (#4), but I never had time for it.

This week I would like to improve some small parts in the build pipeline and add another section to the README.md about your issue #120. Next week I’m busy, but I could start working on this feature the following week.

Of course, your help is always welcome! If you like, just go ahead and start with a feature branch - or we'll work together on this feature. What do you think?

@SbiCA
Copy link
Author

SbiCA commented Aug 15, 2019

@HofmeisterAn sure I would be open for collaboration, since I'm in a similar situation regarding my availability. Maybe we could have a gitter or slack channel for that purpose or what would be your favorite way of having design discussions?

@HofmeisterAn HofmeisterAn changed the title Support for WithDockerCompose Add missing function WithDockerCompose Aug 17, 2019
@HofmeisterAn HofmeisterAn added the enhancement New feature or request label Aug 17, 2019
@HofmeisterAn HofmeisterAn added this to the 1.0.0 milestone Aug 17, 2019
@HofmeisterAn
Copy link
Collaborator

Gitter, Slack or MS Teams would be nice. I'm using all three of them. Anything you prefer? As soon as I’m back next week we can start having design discussions.

@HofmeisterAn
Copy link
Collaborator

@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?

@HofmeisterAn HofmeisterAn modified the milestones: 1.0.0, 2.0.0 Dec 10, 2019
@HofmeisterAn HofmeisterAn removed this from the 2.0.0 milestone Oct 10, 2020
@tcfialho
Copy link

Waiting for this feature too!

@HofmeisterAn
Copy link
Collaborator

I agree, this feature would be great. Maybe you can get in touch with @SbiCA. A pull request is more than welcome. I am happy to help as much as I can, like feature discussions, tests, code reviews, etc. I just can’t bring myself to do all the development now, due other projects.

@SbiCA
Copy link
Author

SbiCA commented Jan 19, 2021

Same here 😢 , sorry for having raised the expectations/adding delay here.

@maranmaran
Copy link

Any way to join?

@HofmeisterAn
Copy link
Collaborator

I think no one started yet. Would you like to start? Maybe some more will join than.

@HofmeisterAn HofmeisterAn added the help wanted Extra attention is needed label Jun 4, 2022
@LoremFooBar
Copy link

I'd be happy to help, is anyone working on it?

@HofmeisterAn
Copy link
Collaborator

I think no one is working on it right now. Contribution is more than welcome.

@LoremFooBar
Copy link

Cool, I'll give it a shot.

@LoremFooBar
Copy link

Thinking about the API design for this, I have a few points to raise:

  1. Since all of the public API surface revolves around working with a single container, I propose this API for compose:

    var compose = new DockerComposeBuilder()
      .WithComposeFile("path/to/docker-compose.yml")
      .Build();
    
    await compose.UpAsync();
    await compose.DownAsync();
  2. Regarding implementation - since compose is not part of the Docker Engine API, and the docker compose command has been part of Docker Desktop for a while now, I assume it is acceptable to use the docker compose command for the different compose methods (docker compose up, docker compose down etc.).

@HofmeisterAn
Copy link
Collaborator

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.

@LoremFooBar
Copy link

The java implementation is spinning a container to run compose commands, I assume because they could not assume docker-compose is 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 now compose is bundled with Docker Desktop.

@maranmaran
Copy link

May I ask how do you plan on implementing this?

https://github.com/mariotoffia/FluentDocker seems neatly implemented.

Are you on official slack? @LoremFooBar

@LoremFooBar
Copy link

Basically by running docker compose commands. I'll ping you on slack.

@hmonzer
Copy link

hmonzer commented Aug 22, 2022

The java implementation is spinning a container to run compose commands, I assume because they could not assume docker-compose is 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 now compose is bundled with Docker Desktop.

what about running these tests as part of the CI pipeline for example?
Probably this is the importance of having a docker image with docker compose client in it

@LoremFooBar
Copy link

The java implementation is spinning a container to run compose commands, I assume because they could not assume docker-compose is 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 now compose is bundled with Docker Desktop.

what about running these tests as part of the CI pipeline for example? Probably this is the importance of having a docker image with docker compose client in it

I find it reasonable to have the developer properly set up a CI environment for their needs, and that includes any binaries required to run their tests. We can ensure a clear error message is displayed when compose is unavailable on the machine. IMO the alternative is over complicated for most cases.

@tabata22
Copy link

tabata22 commented Jan 3, 2023

Any news about it?

@LoremFooBar
Copy link

Unfortunately, I was not able to make much progress eventually.

@FredericVaugeoisFlo
Copy link

Still working on this feature? Currently this is the only feature that still makes us use FluentDocker instead of TestContainers...

@HofmeisterAn
Copy link
Collaborator

I think nobody is working on the Compose support right now.

@nkz-soft
Copy link

Hi @HofmeisterAn
I really need this feature in my project, so I think I can make it happen. I'll keep you updated.

nkz-soft added a commit to nkz-soft/testcontainers-dotnet that referenced this issue Jan 2, 2024
@nkz-soft nkz-soft linked a pull request Jan 2, 2024 that will close this issue
@SeanFarrow
Copy link

is this feature any closer to being merged?
I'm happy to help where I can to get this over the line/on par with the Java version.
The only question is whether we should run a container (to run compose commands) as the Java version does, whether we should check whether docker compose is installed on the target system, whether we should require Docker desktop, or whether we should download and run a version of compose ourselves.

See here for more information.

Thanks,
Sean.

@TabLand
Copy link

TabLand commented Feb 20, 2024

I came across this issue today after being a bit perplexed by the idea of a "Docker Wormhole Configuration"

It feels like a bit of an anti-pattern, and possibly a security concern. In the event that a container is compromised, am I correct in concluding that there is an easy path to instructing the docker daemon to start other containers of any image on the host?

Further reference: https://ro14nd.de/Docker-Wormhole-Pattern

I'll try to build and test patch #1082 over the next few days...

@cvicenti-apr
Copy link

Hey!
What's blocking the already-existing PR? We definitely need something like this in our project.
Thanks

@HofmeisterAn
Copy link
Collaborator

Hey! What's blocking the already-existing PR? We definitely need something like this in our project. Thanks

I reviewed the pull request (#1082) some time ago and have a few suggestions and things I would like to discuss first (nkz-soft#1) before merging the feature and bringing it upstream.

@jvitor83
Copy link

Hi! How this is going? I'm really want to use it.

@HofmeisterAn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.