Skip to content

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

@Agasd

Description

@Agasd

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;

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions