Application works with docker command but not with docker compose

303 views Asked by At

I created tests for my application using docker inside the dotnet tests. It pulls an image from rabbitmq and starts it before testing and it works fine.

Now I'm trying to add these tests to docker, but to run docker inside a container I'm using volumes in docker.sock to transmit the commands to the host machine.

-v /var/run/docker.sock:/var/run/docker.sock

and to make it easier I would like to add this command in docker compose.

the problem is that the tests run correctly using the command

docker run -v /var/run/docker.sock:/var/run/docker.sock -ti rabbitmq-dotnet-app-tests

but it gives the following error using docker-compose

rabbitmq-dotnet-app-tests-1 | Failed tests.DummyTests.RabbitMqTest1.test1 [1 ms] rabbitmq-dotnet-app-tests-1 | Error Message: rabbitmq-dotnet-app-tests-1 | System.AggregateException : One or more errors occurred. (One or more errors occurred. (Initialization has been cancelled.)) (The following constructor parameters did not have matching fixture data: RabbitMqFixture rabbitMqFixture) rabbitmq-dotnet-app-tests-1 | ---- System.AggregateException : One or more errors occurred. (Initialization has been cancelled.) rabbitmq-dotnet-app-tests-1 | -------- DotNet.Testcontainers.Containers.ResourceReaperException : Initialization has been cancelled. rabbitmq-dotnet-app-tests-1 | ---- The following constructor parameters did not have matching fixture data: RabbitMqFixture rabbitMqFixture

my docker compose file

version: "3.8"

services:
  app-tests:
    image: rabbitmq-dotnet-app-tests
    build:
      context: .
      dockerfile: Dockerfile.Tests
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

here is the github link of this application

Im using docker desktop for windows and the test connectionstring is here

0

There are 0 answers