doc/docs/api-reference/csharp/core-classes/container.md
Represents a container inside a session.
public sealed class Container : IDisposable
{
public string Id { get; }
public Process InitProcess { get; }
public ContainerState State { get; }
public void Start();
public void Stop(Signal signal, TimeSpan timeout);
public void Delete(DeleteContainerOption option);
public Process CreateProcess(ProcessSettings newProcessSettings);
public string Inspect();
public void Dispose();
}
Notes:
Start() has no flags parameter.InitProcess.OutputMode is Event or Stream, Start() automatically requests native attach.InitProcess is only available when ContainerSettings.InitProcess was configured.Starts the container and, if configured, attaches the init process handle.
container.Start();
Stops the container with a signal and timeout.
container.Stop(Signal.SIGTERM, TimeSpan.FromSeconds(10));
Deletes the container.
container.Delete(DeleteContainerOption.Force);
Creates a secondary process object inside the container.
var execSettings = new ProcessSettings
{
CommandLine = new List<string> { "/bin/sh", "-c", "echo secondary process" },
OutputMode = ProcessOutputMode.Event
};
Process process = container.CreateProcess(execSettings);
Returns the raw inspect payload as a string.
string inspectJson = container.Inspect();
Console.WriteLine(inspectJson);
Returns the container ID string.
Console.WriteLine(container.Id);
Gets the configured init process object.
Process init = container.InitProcess;
Gets the current container state.
Console.WriteLine(container.State);
Releases the underlying WinRT container object.
container.Dispose();