mariotoffia / FluentDocker

Use docker, docker-compose local and remote in tests and your .NET core/full framework apps via a FluentAPI
Apache License 2.0
1.31k stars 97 forks source link

How to connect with Docker in Docker (dind) in a tekton pipeline #297

Open dosper7 opened 1 year ago

dosper7 commented 1 year ago

I'm trying to execute some integration tests using a docker-compose file that I'm passing it to the FluentDocker.

Locally (windows machine) it works ok because (I assume) I already have the docker running, so the FluentDocker knows how to connect to it.

In my case, I'm running a dind, so the tests are in one pod, and the docker is on another pod, I'm getting this error: Ductus.FluentDocker.Common.FluentDockerException : Failed to find docker client binary - please add it to your path

I was using TestContainers and that was working ok (both locally and in the tekton pipelines) but then I switched to docker-compose to use the same file that we use on our day-to-day work and avoid having different versions in TestContainers vs docker-compose.

How to tell FluetDocker to communicate with that docker engine and not a "local" one? I think it's the http api vs native (correct me if I'm saying anything stupid 😄 )

vmandic commented 1 year ago

+1 interested, I have a dotnet core application that runs tests via dotnet test and I installed docker-cli and docker-compose to my test image with other deps as:

RUN apk add --update nodejs yarn docker-cli docker-compose && rm -rf /var/cache/apk/

And when running pass the docker.sock as volume:

docker run --rm -v $(pwd):/app -v "/var/run/docker.sock:/var/run/docker.sock:rw" -w /app company/test-app yarn test:integration

But as this is already within gitlab DinD image CI/CD in my case I'd love to see if I can skip that.