Пример #1
0
 private string getContainer(string image)
 {
     try
     {
         if (!containers.ContainsKey(image))
         {
             try
             {
                 docker.PullImage(image).Wait();
             }
             catch (Exception ee)
             {
                 logger.LogWarning($"Warning: pull {image} failed");
             }
             var c = docker.CreateContainer(image, "/app", new string[] {
                 $"{workDir}/data/pulls:/app/wn_pulls",
                 $"{workDir}/data/out:/app/wn_out",
                 $"{workDir}/data/app:/app"
             });
             c.Wait();
             logger.LogInformation($"container {c.Result}({image}) created.");
             containers[image] = c.Result;
         }
         return(containers[image]);
     }
     catch (Exception e)
     {
         return(null);
     }
 }