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

Could not dispose composite service #269

Open codechrysalis-doug opened 2 years ago

codechrysalis-doug commented 2 years ago

Hello, I inherited a legacy codebase and am not familiar with C#. The application is dockerized, so I tried running it in AWS ECS and this is the error I received. If this is the wrong place to ask, could you please point me in the right direction?

2022-08-09 17:20:50[08:20:50 ERR] Top Level Exception occured. Trying to soldier on! Could not dispose composite service from file(s) /app/images/node-git-karma/docker-compose.yaml
2022-08-09 17:20:50 Ductus.FluentDocker.Common.FluentDockerException: Could not dispose composite service from file(s) /app/images/node-git-karma/docker-compose.yaml
2022-08-09 17:20:50 at Ductus.FluentDocker.Services.Impl.DockerComposeCompositeService.Dispose()
2022-08-09 17:20:50 at Ductus.FluentDocker.Fd.Run[T](Func`2 builder, Action`1 run, String name)
2022-08-09 17:20:50 at Ductus.FluentDocker.Fd.Composite(Func`2 builder, Action`1 run, String name)

Does anyone have an idea of what this might mean? the image is in there and the file exists, but am not certain on why it's failing.

Here is the version:

<PackageReference Include="Ductus.FluentDocker" Version="2.8.3" />

Here is the code in question:

      var image = Path.Combine(Directory.GetCurrentDirectory(),
        "images",
        ImageName,
        "docker-compose.yaml");

      ...

      Fd.Composite(
        c => c.UseContainer()
          .UseCompose()
          .FromFile(image)
          .RemoveOrphans()
          .ForceBuild(),
        svc =>
        {
          ...
        });
mariotoffia commented 2 years ago

Hi @codechrysalis-doug. Can you, please, check your console (if you enable logging) what docker commands being executed during dispose? If you run those manually what is the output?

codechrysalis-doug commented 2 years ago

Hi @codechrysalis-doug. Can you, please, check your console (if you enable logging) what docker commands being executed during dispose? If you run those manually what is the output?

Hey, thank you for getting back to me! I checked the https://github.com/mariotoffia/FluentDocker#logging and wasn't sure which file that configuration belonged to. Could you explain to me how I can set the logs? I have no experience with C# and it's ecosystems, my apologies.

I did find in the code base there was a logger set, but the logs didn't give the granularity that you mentioned.

    private static void ConfigureLogging()
    {
      Log.Logger = new LoggerConfiguration()
        .MinimumLevel.Debug()
        .WriteTo.Console()
        .CreateLogger();
    }
codechrysalis-doug commented 2 years ago

Hi @codechrysalis-doug. Can you, please, check your console (if you enable logging) what docker commands being executed during dispose? If you run those manually what is the output?

Follow-up: I tried to enable logging and a few other things and I wasn't able to get the FluentDocker to give me the logs even with log level debug. It does show me the error, but that's it. Do you have an example project for how I can get the logs from FluentDocker running the container?

mariotoffia commented 2 years ago

Hi @codechrysalis-doug sorry for late reply. Can you please test LoggerTests.cs.

If it works properly, you should get the following log statements.

Ductus.FluentDocker: message 1
Ductus.FluentDocker: message 2
Ductus.FluentDocker: message 3

Btw do you enable logging via

Logging.Enabled();

Cheers, Mario :)

gbirchmeier commented 1 year ago

Get anywhere on this? I'm finding a possibly similar issue.

The error is: Ductus.FluentDocker.Common.FluentDockerException : Could not dispose composite service from file(s) docker-compose.yaml

and the top of the stacktrace is just a call to

    _compose.Dispose(); // var is a DockerComposeCompositeService

It's not much help in diagnosing the problem.

codechrysalis-doug commented 1 year ago

Get anywhere on this? I'm finding a possibly similar issue.

The error is: Ductus.FluentDocker.Common.FluentDockerException : Could not dispose composite service from file(s) docker-compose.yaml

and the top of the stacktrace is just a call to

    _compose.Dispose(); // var is a DockerComposeCompositeService

It's not much help in diagnosing the problem.

I made some progress by further debugging into the application level. It seems the errors didn't bubble up in our situation, but we ultimately decided to move away from using this all together in favor of a more cloud native solution.

codechrysalis-doug commented 6 days ago

Hi again

Hi @codechrysalis-doug sorry for late reply. Can you please test LoggerTests.cs.

If it works properly, you should get the following log statements.

Ductus.FluentDocker: message 1
Ductus.FluentDocker: message 2
Ductus.FluentDocker: message 3

Btw do you enable logging via

Logging.Enabled();

Cheers, Mario :)

Hi again Mario! it's been 2 years and I had to test this codebase again. Upon trying Logging.Enabled();, I wasn't able to find any additional clues. Do you have any other ideas for how I can debug this?