FluentDocker icon indicating copy to clipboard operation
FluentDocker copied to clipboard

Could not dispose composite service

Open codechrysalis-doug opened this issue 3 years ago • 7 comments

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 =>
        {
          ...
        });

codechrysalis-doug avatar Aug 09 '22 08:08 codechrysalis-doug

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?

mariotoffia avatar Aug 11 '22 07:08 mariotoffia

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 avatar Aug 11 '22 07:08 codechrysalis-doug

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?

codechrysalis-doug avatar Aug 20 '22 08:08 codechrysalis-doug

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 :)

mariotoffia avatar Aug 22 '22 07:08 mariotoffia

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.

gbirchmeier avatar Mar 15 '23 22:03 gbirchmeier

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 avatar Mar 16 '23 03:03 codechrysalis-doug