func SaveImage(image string) ([]byte, error) {
    ctx := context.Background()
    cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
    if err != nil {
        return nil, err
    }
    defer cli.Close()

    resp, err := cli.ImageSave(ctx, []string{image})
    if err != nil {
        return nil, err
    }
    defer resp.Close()

    savedImageTar, err := ioutil.ReadAll(resp)
    if err != nil {
        return nil, err
    }

    return savedImageTar, nil
}
// Save an image into a tar archive format
// Returns the tar archive in byte slice
Save an image into a tar archive format
Returns the tar archive in byte slice
// Save an image into a tar archive format // Returns the tar archive in byte slice
func SaveImage(image string) ([]byte, error) {
    ctx := context.Background()
    cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
    if err != nil {
        return nil, err
    }
    defer cli.Close()
    resp, err := cli.ImageSave(ctx, []string{image})
    if err != nil {
        return nil, err
    }
    defer resp.Close()
    savedImageTar, err := ioutil.ReadAll(resp)
    if err != nil {
        return nil, err
    }
    return savedImageTar, nil
}
func SaveImage ( image string ) ( [ ] byte , error ) { ctx := context . Background ( ) cli , err := client . NewClientWithOpts ( client . FromEnv , client . WithAPIVersionNegotiation ( ) ) if err != nil { return nil , err } defer cli . Close ( ) resp , err := cli . ImageSave ( ctx , [ ] string { image } ) if err != nil { return nil , err } defer resp . Close ( ) savedImageTar , err := ioutil . ReadAll ( resp ) if err != nil { return nil , err } return savedImageTar , nil }
Save an image into a tar archive format
Returns the tar archive in byte slice
Save an image into a tar archive format Returns the tar archive in byte slice