mariotoffia / FluentDocker

Use docker, docker-compose local and remote in tests and your .NET core/full framework apps via a FluentAPI
Apache License 2.0
1.31k stars 97 forks source link

Missing docker's load #288

Open mynote opened 1 year ago

mynote commented 1 year ago

I'm not sure if i am wrong, but I couldn't find a wrapper for docker's load functionality for offline usage.

Example:
docker save --output myimage.tar myimage
docker load --input myimage.tar

mariotoffia commented 1 year ago

@mynote That is true! If you'd like, please submit a PR that implements those commands (Commands/client.cs) - around this fashion:

    public static CommandResponse<IList<string>> Load(this DockerUri host, string image, bool quiet = true, ICertificatePaths certificates = null)
    {
      var args = $"{host.RenderBaseArgs(certificates)}";
      var options = string.Empty;

     if (quiet) {
      options += "--quiet";
    }

      return
        new ProcessExecutor<StringListResponseParser, IList<string>>(
          "docker".ResolveBinary(),
          $"{args} load --input {image} {options}").Execute();
    }

...and a unit test to save and then load the image...

Cheers, Mario

mynote commented 1 year ago

Thank you, Mario. Cheers, Emanuel