예제 #1
0
        public long Docker(string image, string command, out string stdout, out string stderr)
        {
            var container = getContainer(image);

            if (container == null)
            {
                stdout = "";
                stderr = $"cannot create a container of image `{image}`";
                return(-2);
            }
            logger.LogInformation($"execute in {container}({image}): {command}");
            var tsk = docker.RunCommandInContainerAsync(container,
                                                        command, timeout);

            tsk.Wait();

            stdout = tsk.Result.stdout;
            stderr = tsk.Result.stderr;
            return(tsk.Result.exitCode);
        }