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

"running" state never entered after calling GetNetworks() or GetVolumes() #253

Closed
Agasd opened this issue May 4, 2022 · 2 comments
Closed
Assignees
Milestone

Comments

@Agasd
Copy link
Contributor

Agasd commented May 4, 2022

If I run IContainerService.GetNetworks(); or IContainerService.GetVolumes(); before I start the container then IContainerService.State never becomes ServiceRunningState.Running;

The container itself does enter the running state.

Example code:

var container =
  new Ductus.FluentDocker.Builders.Builder().UseContainer()
    .UseImage("alpine")
    .MountVolume("test", "/dev/test", Ductus.FluentDocker.Model.Builders.MountType.ReadWrite)
    .Command("tail", "-f", "/dev/null")
    .KeepContainer()
    .ExposePort(5432)
    .WaitForPort("5432/tcp", 30000 /*30s*/)
    .KeepRunning()
    .Build();

container.GetNetworks(); //If I remove this line it works again
container.Start();
var test = container.State == ServiceRunningState.Running; //false
Console.ReadKey();

This workaround fixes the issue:

var container =
  new Ductus.FluentDocker.Builders.Builder().UseContainer()
    .UseImage("alpine")
    .MountVolume("test", "/dev/test", Ductus.FluentDocker.Model.Builders.MountType.ReadWrite)
    .Command("tail", "-f", "/dev/null")
    .KeepContainer()
    .ExposePort(5432)
    .WaitForPort("5432/tcp", 30000 /*30s*/)
    .KeepRunning()
    .Build();

container.Start();
container.GetNetworks(); 
container.GetConfiguration(true); //If I add this line works
var test = container.State == ServiceRunningState.Running; //true
Console.ReadKey();

So I guess the issue is in DockerContainerService.cs:160

      if (GetConfiguration().State.Running)
        State = ServiceRunningState.Running;
@mariotoffia mariotoffia self-assigned this May 30, 2022
@mariotoffia mariotoffia added this to the 3.0.0-RELEASE milestone May 30, 2022
@mariotoffia
Copy link
Owner

Thanks @Agasd - I'll put this on my backlog! :)

@mariotoffia
Copy link
Owner

Nice and thanks for resolving this!

Cheers,
Mario :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants