English 中文(简体)
• 如何打听从剪辑申请的 do
原标题:How to call docker run from c# application
  • 时间:2017-07-25 16:32:49
  •  标签:
  • c#
  • wpf
  • docker

我提出WPF申请,在处理档案时,需要使用cker器。 码头集装箱在箱子上建,目前是在处理WPF申请的档案之后,用户必须迅速启动指挥和类型。

docker run --it --rm -v folderdedirect process parameters_including_filePath

进行进一步处理。

我想将这一点列入世界森林论坛的申请。 我可以推定使用<代码>system.diagnostics.process with cmd.exe? 我看见<条码>Docker.dotnet,但我生的灯塔说明它为什么要经营当地集装箱。

最佳回答

在这方面,我如何最终这样做,但也许有更好的办法。

var processInfo = new ProcessStartInfo("docker", $"run -it --rm blahblahblah");

processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
processInfo.RedirectStandardError = true;

int exitCode;
using (var process = new Process())
{
    process.StartInfo = processInfo;
    process.OutputDataReceived += new DataReceivedEventHandler(logOrWhatever());
    process.ErrorDataReceived += new DataReceivedEventHandler(logOrWhatever());

    process.Start();
    process.BeginOutputReadLine();
    process.BeginErrorReadLine();
    process.WaitForExit(1200000);
    if (!process.HasExited)
    {
        process.Kill();
    }

    exitCode = process.ExitCode;
    process.Close();
}
问题回答

更现代的解决办法将包含一揽子方案

DotNet. 测试设备。

这里使用的编码样本:

ContainerBuilder builder = new ContainerBuilder()
              // use particular version always 
              .WithImage("postgres")
              // name it nicely
              .WithName("PSQL")
              .WithBindMount("/var/run/docker.sock", "/var/run/docker.sock")
              // with some configuration
              .WithEnvironment(new Dictionary<string, string>())
              .WithEnvironment("DOCKER_HOST", "unix:///var/run/docker.sock")
              .WithWaitStrategy(Wait.ForUnixContainer())
              .WithOutputConsumer(Consume.RedirectStdoutAndStderrToConsole());

        builder = builder.WithPortBinding(5432, 5432);
        PsqlStack = builder.Build();
        await PsqlStack.StartAsync();




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签