【发布时间】:2019-07-08 08:51:16
【问题描述】:
我想用Docker.DotNet 提取并运行一个图像,我很绝望,我不知道如何使用这个库来做到这一点。
谁能帮帮我?
我查看了https://github.com/microsoft/Docker.DotNet 上的教程,但没有帮助。
public class DockerService
{
private readonly DockerClient DockerClient;
public DockerService()
{
if (OperatingSystem.IsWindows())
{
DockerClient = new DockerClientConfiguration(new Uri("npipe://./pipe/docker_engine")).CreateClient();
}
else if (OperatingSystem.IsLinux())
{
DockerClient = new DockerClientConfiguration(new Uri("unix:///var/run/docker.sock")).CreateClient();
}
else
{
throw new Exception("unknown operation system");
}
}
public void StartCompose()
{
var progress = new Progress<JSONMessage>();
var task = PullImage(
new ImagesCreateParameters()
{
FromImage = "mcr.microsoft.com/dotnet/core/sdk",
Tag = "latest"
},null,
progress);
task.Wait();
}
private Task PullImage(ImagesCreateParameters imagesCreateParameters, AuthConfig authConfig,
Progress<JSONMessage> progress)
{
return DockerClient.Images.CreateImageAsync(imagesCreateParameters, authConfig, progress);
}
}
我希望在启动 task.wait() 时会发生一些事情?但它运行了几分钟,没有任何反应。
【问题讨论】:
-
如果github.com/dotnet/… 的文档和这篇文章一样好就好了....