public static void Login(string username, string password, string server, bool isDryRun) { Version clientVersion = GetClientVersion(); if (clientVersion >= new Version(17, 7)) { ProcessStartInfo startInfo = new ProcessStartInfo( "docker", $"login -u {username} --password-stdin {server}") { RedirectStandardInput = true }; ExecuteHelper.ExecuteWithRetry( startInfo, process => { process.StandardInput.WriteLine(password); process.StandardInput.Close(); }, isDryRun); } else { ExecuteHelper.ExecuteWithRetry( "docker", $"login -u {username} -p {password} {server}", isDryRun, executeMessageOverride: $"login -u {username} -p ******** {server}"); } }
public string?BuildImage( string dockerfilePath, string buildContextPath, string platform, IEnumerable <string> tags, IDictionary <string, string?> buildArgs, bool isRetryEnabled, bool isDryRun) { string tagArgs = $"-t {string.Join(" -t ", tags)}"; IEnumerable <string> buildArgList = buildArgs .Select(buildArg => $" --build-arg {buildArg.Key}={buildArg.Value}"); string buildArgsString = string.Join(string.Empty, buildArgList); string dockerArgs = $"build --platform {platform} {tagArgs} -f {dockerfilePath}{buildArgsString} {buildContextPath}"; if (isRetryEnabled) { return(ExecuteHelper.ExecuteWithRetry("docker", dockerArgs, isDryRun)); } else { return(ExecuteHelper.Execute("docker", dockerArgs, isDryRun)); } }
public static void PullBaseImages(ManifestInfo manifest, Options options) { Utilities.WriteHeading("PULLING LATEST BASE IMAGES"); foreach (string fromImage in manifest.GetExternalFromImages()) { ExecuteHelper.ExecuteWithRetry("docker", $"pull {fromImage}", options.IsDryRun); } }
public JArray Inspect(string image, bool isDryRun) { string output = ExecuteHelper.ExecuteWithRetry("manifest-tool", $"inspect {image} --raw", isDryRun); if (isDryRun) { return(null); } return(JsonConvert.DeserializeObject <JArray>(output)); }
public static void PullBaseImages(ManifestInfo manifest, Options options) { Logger.WriteHeading("PULLING LATEST BASE IMAGES"); IEnumerable <string> baseImages = manifest.GetExternalFromImages().ToArray(); if (baseImages.Any()) { foreach (string fromImage in baseImages) { ExecuteHelper.ExecuteWithRetry("docker", $"pull {fromImage}", options.IsDryRun); } } else { Logger.WriteMessage("No external base images to pull"); } }
private static void Logout(string server, bool isDryRun) { ExecuteHelper.ExecuteWithRetry("docker", $"logout {server}", isDryRun); }
public static void PullImage(string image, bool isDryRun) { ExecuteHelper.ExecuteWithRetry("docker", $"pull {image}", isDryRun); }
public void PushImage(string tag, bool isDryRun) => ExecuteHelper.ExecuteWithRetry("docker", $"push {tag}", isDryRun);
public void PushFromSpec(string manifestFile, bool isDryRun) { // ExecuteWithRetry because the manifest-tool fails periodically while communicating // with the Docker Registry. ExecuteHelper.ExecuteWithRetry("manifest-tool", $"push from-spec {manifestFile}", isDryRun); }