2014-02-25 16:17:48 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-07-14 18:02:38 +00:00
|
|
|
"context"
|
2023-09-22 11:17:33 +00:00
|
|
|
"encoding/json"
|
2014-02-25 16:17:48 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
2014-09-06 11:49:40 +00:00
|
|
|
"path/filepath"
|
2014-11-11 09:18:22 +00:00
|
|
|
"strings"
|
2019-09-09 21:06:12 +00:00
|
|
|
"testing"
|
2015-04-18 16:46:47 +00:00
|
|
|
|
2023-09-22 11:17:33 +00:00
|
|
|
"github.com/docker/docker/api/types"
|
2023-07-27 17:56:27 +00:00
|
|
|
"github.com/docker/docker/integration-cli/cli"
|
2017-03-23 17:35:22 +00:00
|
|
|
"github.com/docker/docker/integration-cli/cli/build"
|
2023-12-05 10:59:19 +00:00
|
|
|
"github.com/docker/docker/internal/testutils/specialimage"
|
2020-02-07 13:39:24 +00:00
|
|
|
"gotest.tools/v3/assert"
|
2023-09-22 11:17:33 +00:00
|
|
|
is "gotest.tools/v3/assert/cmp"
|
2020-02-07 13:39:24 +00:00
|
|
|
"gotest.tools/v3/icmd"
|
2023-09-22 11:17:24 +00:00
|
|
|
"gotest.tools/v3/skip"
|
2014-02-25 16:17:48 +00:00
|
|
|
)
|
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
type DockerCLISaveLoadSuite struct {
|
|
|
|
ds *DockerSuite
|
|
|
|
}
|
|
|
|
|
2023-07-14 18:02:38 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
|
|
s.ds.TearDownTest(ctx, c)
|
2022-06-16 21:32:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerCLISaveLoadSuite) OnTimeout(c *testing.T) {
|
|
|
|
s.ds.OnTimeout(c)
|
|
|
|
}
|
|
|
|
|
2014-12-08 20:40:27 +00:00
|
|
|
// save a repo using gz compression and try to load it using stdout
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TestSaveXzAndLoadRepoStdout(c *testing.T) {
|
2015-08-28 17:36:42 +00:00
|
|
|
testRequires(c, DaemonIsLinux)
|
2015-05-16 14:59:53 +00:00
|
|
|
name := "test-save-xz-and-load-repo-stdout"
|
2023-07-27 17:56:27 +00:00
|
|
|
cli.DockerCmd(c, "run", "--name", name, "busybox", "true")
|
2014-12-08 20:40:27 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
imgRepoName := "foobar-save-load-test-xz-gz"
|
|
|
|
out := cli.DockerCmd(c, "commit", name, imgRepoName).Combined()
|
2014-12-08 20:40:27 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
cli.DockerCmd(c, "inspect", imgRepoName)
|
2014-12-08 20:40:27 +00:00
|
|
|
|
2017-08-22 21:07:52 +00:00
|
|
|
repoTarball, err := RunCommandPipelineWithOutput(
|
2023-07-27 17:56:27 +00:00
|
|
|
exec.Command(dockerBinary, "save", imgRepoName),
|
2015-02-14 22:25:13 +00:00
|
|
|
exec.Command("xz", "-c"),
|
|
|
|
exec.Command("gzip", "-c"))
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err, "failed to save repo: %v %v", out, err)
|
2023-07-27 17:56:27 +00:00
|
|
|
deleteImages(imgRepoName)
|
2014-12-08 20:40:27 +00:00
|
|
|
|
2017-01-16 15:39:12 +00:00
|
|
|
icmd.RunCmd(icmd.Cmd{
|
|
|
|
Command: []string{dockerBinary, "load"},
|
|
|
|
Stdin: strings.NewReader(repoTarball),
|
|
|
|
}).Assert(c, icmd.Expected{
|
|
|
|
ExitCode: 1,
|
|
|
|
})
|
2014-12-08 20:40:27 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
after, _, err := dockerCmdWithError("inspect", imgRepoName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "", "the repo should not exist: %v", after)
|
2014-12-08 20:40:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// save a repo using xz+gz compression and try to load it using stdout
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TestSaveXzGzAndLoadRepoStdout(c *testing.T) {
|
2015-08-28 17:36:42 +00:00
|
|
|
testRequires(c, DaemonIsLinux)
|
2015-05-16 14:59:53 +00:00
|
|
|
name := "test-save-xz-gz-and-load-repo-stdout"
|
2023-07-27 17:56:27 +00:00
|
|
|
cli.DockerCmd(c, "run", "--name", name, "busybox", "true")
|
2014-12-08 20:40:27 +00:00
|
|
|
|
|
|
|
repoName := "foobar-save-load-test-xz-gz"
|
2023-07-27 17:56:27 +00:00
|
|
|
cli.DockerCmd(c, "commit", name, repoName)
|
2014-12-08 20:40:27 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
cli.DockerCmd(c, "inspect", repoName)
|
2014-12-08 20:40:27 +00:00
|
|
|
|
2017-08-22 21:07:52 +00:00
|
|
|
out, err := RunCommandPipelineWithOutput(
|
2015-02-14 22:25:13 +00:00
|
|
|
exec.Command(dockerBinary, "save", repoName),
|
|
|
|
exec.Command("xz", "-c"),
|
|
|
|
exec.Command("gzip", "-c"))
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err, "failed to save repo: %v %v", out, err)
|
2014-12-08 20:40:27 +00:00
|
|
|
|
|
|
|
deleteImages(repoName)
|
|
|
|
|
2017-01-16 15:39:12 +00:00
|
|
|
icmd.RunCmd(icmd.Cmd{
|
|
|
|
Command: []string{dockerBinary, "load"},
|
|
|
|
Stdin: strings.NewReader(out),
|
|
|
|
}).Assert(c, icmd.Expected{
|
|
|
|
ExitCode: 1,
|
|
|
|
})
|
2014-12-08 20:40:27 +00:00
|
|
|
|
2015-07-27 18:13:25 +00:00
|
|
|
after, _, err := dockerCmdWithError("inspect", repoName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "", "the repo should not exist: %v", after)
|
2014-12-08 20:40:27 +00:00
|
|
|
}
|
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TestSaveSingleTag(c *testing.T) {
|
2015-08-28 17:36:42 +00:00
|
|
|
testRequires(c, DaemonIsLinux)
|
2023-07-27 17:56:27 +00:00
|
|
|
imgRepoName := "foobar-save-single-tag-test"
|
|
|
|
cli.DockerCmd(c, "tag", "busybox:latest", fmt.Sprintf("%v:latest", imgRepoName))
|
2014-07-07 18:58:27 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
out := cli.DockerCmd(c, "images", "-q", "--no-trunc", imgRepoName).Stdout()
|
2015-04-06 13:21:18 +00:00
|
|
|
cleanedImageID := strings.TrimSpace(out)
|
2014-07-07 18:58:27 +00:00
|
|
|
|
2023-09-22 11:17:22 +00:00
|
|
|
filesFilter := fmt.Sprintf("(^manifest.json$|%v)", cleanedImageID)
|
|
|
|
if testEnv.UsingSnapshotter() {
|
|
|
|
filesFilter = fmt.Sprintf("(^index.json$|^manifest.json$|%v)", cleanedImageID)
|
|
|
|
}
|
2017-08-22 21:07:52 +00:00
|
|
|
out, err := RunCommandPipelineWithOutput(
|
2023-07-27 17:56:27 +00:00
|
|
|
exec.Command(dockerBinary, "save", fmt.Sprintf("%v:latest", imgRepoName)),
|
2015-02-14 22:25:13 +00:00
|
|
|
exec.Command("tar", "t"),
|
2023-09-22 11:17:22 +00:00
|
|
|
exec.Command("grep", "-E", filesFilter))
|
|
|
|
assert.NilError(c, err, "failed to save repo with image ID and index files: %s, %v", out, err)
|
2014-07-07 18:58:27 +00:00
|
|
|
}
|
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TestSaveImageId(c *testing.T) {
|
2015-08-28 17:36:42 +00:00
|
|
|
testRequires(c, DaemonIsLinux)
|
2023-12-05 10:59:19 +00:00
|
|
|
|
|
|
|
emptyFSImage := loadSpecialImage(c, specialimage.EmptyFS)
|
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
imgRepoName := "foobar-save-image-id-test"
|
2023-12-05 10:59:19 +00:00
|
|
|
cli.DockerCmd(c, "tag", emptyFSImage, fmt.Sprintf("%v:latest", imgRepoName))
|
2014-07-07 18:58:27 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
out := cli.DockerCmd(c, "images", "-q", "--no-trunc", imgRepoName).Stdout()
|
2015-11-18 22:20:54 +00:00
|
|
|
cleanedLongImageID := strings.TrimPrefix(strings.TrimSpace(out), "sha256:")
|
2014-07-07 18:58:27 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
out = cli.DockerCmd(c, "images", "-q", imgRepoName).Stdout()
|
2015-04-06 13:21:18 +00:00
|
|
|
cleanedShortImageID := strings.TrimSpace(out)
|
2014-07-07 18:58:27 +00:00
|
|
|
|
2015-08-22 12:06:48 +00:00
|
|
|
// Make sure IDs are not empty
|
2019-09-09 21:08:22 +00:00
|
|
|
assert.Assert(c, cleanedLongImageID != "", "Id should not be empty.")
|
|
|
|
assert.Assert(c, cleanedShortImageID != "", "Id should not be empty.")
|
2015-08-22 12:06:48 +00:00
|
|
|
|
2015-02-14 22:25:13 +00:00
|
|
|
saveCmd := exec.Command(dockerBinary, "save", cleanedShortImageID)
|
|
|
|
tarCmd := exec.Command("tar", "t")
|
2015-07-21 18:01:24 +00:00
|
|
|
|
|
|
|
var err error
|
2015-02-14 22:25:13 +00:00
|
|
|
tarCmd.Stdin, err = saveCmd.StdoutPipe()
|
2019-09-11 10:57:29 +00:00
|
|
|
assert.Assert(c, err == nil, "cannot set stdout pipe for tar: %v", err)
|
2015-02-14 22:25:13 +00:00
|
|
|
grepCmd := exec.Command("grep", cleanedLongImageID)
|
|
|
|
grepCmd.Stdin, err = tarCmd.StdoutPipe()
|
2019-09-11 10:57:29 +00:00
|
|
|
assert.Assert(c, err == nil, "cannot set stdout pipe for grep: %v", err)
|
2014-07-07 18:58:27 +00:00
|
|
|
|
2019-09-11 10:57:29 +00:00
|
|
|
assert.Assert(c, tarCmd.Start() == nil, "tar failed with error: %v", err)
|
|
|
|
assert.Assert(c, saveCmd.Start() == nil, "docker save failed with error: %v", err)
|
2015-02-24 18:33:18 +00:00
|
|
|
defer func() {
|
|
|
|
saveCmd.Wait()
|
|
|
|
tarCmd.Wait()
|
2023-07-27 17:56:27 +00:00
|
|
|
cli.DockerCmd(c, "rmi", imgRepoName)
|
2015-02-24 18:33:18 +00:00
|
|
|
}()
|
2015-02-14 22:25:13 +00:00
|
|
|
|
|
|
|
out, _, err = runCommandWithOutput(grepCmd)
|
|
|
|
|
2019-09-11 10:57:29 +00:00
|
|
|
assert.Assert(c, err == nil, "failed to save repo with image ID: %s, %v", out, err)
|
2014-07-07 18:58:27 +00:00
|
|
|
}
|
|
|
|
|
2014-06-17 01:01:38 +00:00
|
|
|
// save a repo and try to load it using flags
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TestSaveAndLoadRepoFlags(c *testing.T) {
|
2015-08-28 17:36:42 +00:00
|
|
|
testRequires(c, DaemonIsLinux)
|
2023-07-27 17:56:27 +00:00
|
|
|
const name = "test-save-and-load-repo-flags"
|
|
|
|
cli.DockerCmd(c, "run", "--name", name, "busybox", "true")
|
2015-07-21 18:01:24 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
const imgRepoName = "foobar-save-load-test"
|
2014-06-17 01:01:38 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
deleteImages(imgRepoName)
|
|
|
|
cli.DockerCmd(c, "commit", name, imgRepoName)
|
2014-06-17 01:01:38 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
beforeStr := cli.DockerCmd(c, "inspect", imgRepoName).Stdout()
|
2014-06-17 01:01:38 +00:00
|
|
|
|
2017-08-22 21:07:52 +00:00
|
|
|
out, err := RunCommandPipelineWithOutput(
|
2023-07-27 17:56:27 +00:00
|
|
|
exec.Command(dockerBinary, "save", imgRepoName),
|
2015-02-14 22:25:13 +00:00
|
|
|
exec.Command(dockerBinary, "load"))
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err, "failed to save and load repo: %s, %v", out, err)
|
2014-06-17 01:01:38 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
afterStr := cli.DockerCmd(c, "inspect", imgRepoName).Stdout()
|
2023-09-22 11:17:33 +00:00
|
|
|
|
|
|
|
var before, after []types.ImageInspect
|
|
|
|
err = json.Unmarshal([]byte(beforeStr), &before)
|
|
|
|
assert.NilError(c, err, "failed to parse inspect 'before' output")
|
|
|
|
err = json.Unmarshal([]byte(afterStr), &after)
|
|
|
|
assert.NilError(c, err, "failed to parse inspect 'after' output")
|
|
|
|
|
|
|
|
assert.Assert(c, is.Len(before, 1))
|
|
|
|
assert.Assert(c, is.Len(after, 1))
|
|
|
|
|
|
|
|
if testEnv.UsingSnapshotter() {
|
|
|
|
// Ignore LastTagTime difference with c8d.
|
|
|
|
// It is not stored in the image archive, but in the imageStore
|
|
|
|
// which is a graphdrivers implementation detail.
|
|
|
|
//
|
|
|
|
// It works because we load the image into the same daemon which saved
|
|
|
|
// the image. It would still fail with the graphdrivers if the image
|
|
|
|
// was loaded into a different daemon (which should be the case in a
|
|
|
|
// real-world scenario).
|
|
|
|
before[0].Metadata.LastTagTime = after[0].Metadata.LastTagTime
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Check(c, is.DeepEqual(before, after), "inspect is not the same after a save / load")
|
2014-02-25 16:17:48 +00:00
|
|
|
}
|
2014-08-29 01:33:13 +00:00
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TestSaveWithNoExistImage(c *testing.T) {
|
2016-03-04 10:05:34 +00:00
|
|
|
testRequires(c, DaemonIsLinux)
|
|
|
|
|
|
|
|
imgName := "foobar-non-existing-image"
|
|
|
|
|
|
|
|
out, _, err := dockerCmdWithError("save", "-o", "test-img.tar", imgName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "", "save image should fail for non-existing image")
|
|
|
|
assert.Assert(c, strings.Contains(out, fmt.Sprintf("No such image: %s", imgName)))
|
2016-03-04 10:05:34 +00:00
|
|
|
}
|
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TestSaveMultipleNames(c *testing.T) {
|
2015-08-28 17:36:42 +00:00
|
|
|
testRequires(c, DaemonIsLinux)
|
2023-12-05 10:59:19 +00:00
|
|
|
|
|
|
|
emptyFSImage := loadSpecialImage(c, specialimage.EmptyFS)
|
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
const imgRepoName = "foobar-save-multi-name-test"
|
2014-08-29 01:33:13 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
oneTag := fmt.Sprintf("%v-one:latest", imgRepoName)
|
|
|
|
twoTag := fmt.Sprintf("%v-two:latest", imgRepoName)
|
2014-11-17 16:05:49 +00:00
|
|
|
|
2023-12-05 10:59:19 +00:00
|
|
|
cli.DockerCmd(c, "tag", emptyFSImage, oneTag)
|
|
|
|
cli.DockerCmd(c, "tag", emptyFSImage, twoTag)
|
2014-08-29 01:33:13 +00:00
|
|
|
|
2017-08-22 21:07:52 +00:00
|
|
|
out, err := RunCommandPipelineWithOutput(
|
2023-09-22 11:17:22 +00:00
|
|
|
exec.Command(dockerBinary, "save", strings.TrimSuffix(oneTag, ":latest"), twoTag),
|
|
|
|
exec.Command("tar", "xO", "index.json"),
|
2015-02-14 22:25:13 +00:00
|
|
|
)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err, "failed to save multiple repos: %s, %v", out, err)
|
2023-09-22 11:17:22 +00:00
|
|
|
|
|
|
|
assert.Check(c, is.Contains(out, oneTag))
|
|
|
|
assert.Check(c, is.Contains(out, twoTag))
|
2014-08-29 01:33:13 +00:00
|
|
|
}
|
2014-09-06 11:49:40 +00:00
|
|
|
|
2015-11-24 01:20:44 +00:00
|
|
|
// Test loading a weird image where one of the layers is of zero size.
|
|
|
|
// The layer.tar file is actually zero bytes, no padding or anything else.
|
|
|
|
// See issue: 18170
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TestLoadZeroSizeLayer(c *testing.T) {
|
2023-09-22 11:17:24 +00:00
|
|
|
// TODO(vvoland): Create an OCI image with 0 bytes layer.
|
|
|
|
skip.If(c, testEnv.UsingSnapshotter(), "input archive is not OCI compatible")
|
|
|
|
|
2018-05-04 21:15:00 +00:00
|
|
|
// this will definitely not work if using remote daemon
|
|
|
|
// very weird test
|
2018-12-24 12:25:53 +00:00
|
|
|
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
|
2015-11-24 01:20:44 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
cli.DockerCmd(c, "load", "-i", "testdata/emptyLayer.tar")
|
2015-11-24 01:20:44 +00:00
|
|
|
}
|
2016-03-21 20:52:36 +00:00
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TestSaveLoadParents(c *testing.T) {
|
2016-03-21 20:52:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux)
|
2023-09-22 11:17:26 +00:00
|
|
|
skip.If(c, testEnv.UsingSnapshotter(), "Parent image property is not supported with containerd")
|
2016-03-21 20:52:36 +00:00
|
|
|
|
|
|
|
makeImage := func(from string, addfile string) string {
|
2023-07-27 17:56:27 +00:00
|
|
|
id := cli.DockerCmd(c, "run", "-d", from, "touch", addfile).Stdout()
|
|
|
|
id = strings.TrimSpace(id)
|
2016-03-21 20:52:36 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
imageID := cli.DockerCmd(c, "commit", id).Stdout()
|
|
|
|
imageID = strings.TrimSpace(imageID)
|
2016-03-21 20:52:36 +00:00
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
cli.DockerCmd(c, "rm", "-f", id)
|
2016-03-21 20:52:36 +00:00
|
|
|
return imageID
|
|
|
|
}
|
|
|
|
|
|
|
|
idFoo := makeImage("busybox", "foo")
|
|
|
|
idBar := makeImage(idFoo, "bar")
|
|
|
|
|
2021-08-24 10:10:50 +00:00
|
|
|
tmpDir, err := os.MkdirTemp("", "save-load-parents")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-03-21 20:52:36 +00:00
|
|
|
defer os.RemoveAll(tmpDir)
|
|
|
|
|
|
|
|
c.Log("tmpdir", tmpDir)
|
|
|
|
|
|
|
|
outfile := filepath.Join(tmpDir, "out.tar")
|
|
|
|
|
2023-07-27 17:56:27 +00:00
|
|
|
cli.DockerCmd(c, "save", "-o", outfile, idBar, idFoo)
|
|
|
|
cli.DockerCmd(c, "rmi", idBar)
|
|
|
|
cli.DockerCmd(c, "load", "-i", outfile)
|
2016-03-21 20:52:36 +00:00
|
|
|
|
|
|
|
inspectOut := inspectField(c, idBar, "Parent")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.Equal(c, inspectOut, idFoo)
|
2016-03-21 20:52:36 +00:00
|
|
|
|
|
|
|
inspectOut = inspectField(c, idFoo, "Parent")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.Equal(c, inspectOut, "")
|
2016-03-21 20:52:36 +00:00
|
|
|
}
|
2016-05-26 01:25:12 +00:00
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLISaveLoadSuite) TestSaveLoadNoTag(c *testing.T) {
|
2016-05-26 01:25:12 +00:00
|
|
|
testRequires(c, DaemonIsLinux)
|
|
|
|
|
|
|
|
name := "saveloadnotag"
|
|
|
|
|
2017-03-23 17:35:22 +00:00
|
|
|
buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nENV foo=bar"))
|
2016-05-26 01:25:12 +00:00
|
|
|
id := inspectField(c, name, "Id")
|
|
|
|
|
|
|
|
// Test to make sure that save w/o name just shows imageID during load
|
2017-08-22 21:07:52 +00:00
|
|
|
out, err := RunCommandPipelineWithOutput(
|
2016-05-26 01:25:12 +00:00
|
|
|
exec.Command(dockerBinary, "save", id),
|
|
|
|
exec.Command(dockerBinary, "load"))
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err, "failed to save and load repo: %s, %v", out, err)
|
2016-05-26 01:25:12 +00:00
|
|
|
|
|
|
|
// Should not show 'name' but should show the image ID during the load
|
2019-09-09 21:07:46 +00:00
|
|
|
assert.Assert(c, !strings.Contains(out, "Loaded image: "))
|
2019-09-09 21:08:22 +00:00
|
|
|
assert.Assert(c, strings.Contains(out, "Loaded image ID:"))
|
|
|
|
assert.Assert(c, strings.Contains(out, id))
|
2016-05-26 01:25:12 +00:00
|
|
|
// Test to make sure that save by name shows that name during load
|
2017-08-22 21:07:52 +00:00
|
|
|
out, err = RunCommandPipelineWithOutput(
|
2016-05-26 01:25:12 +00:00
|
|
|
exec.Command(dockerBinary, "save", name),
|
|
|
|
exec.Command(dockerBinary, "load"))
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err, "failed to save and load repo: %s, %v", out, err)
|
|
|
|
|
2019-09-09 21:08:22 +00:00
|
|
|
assert.Assert(c, strings.Contains(out, "Loaded image: "+name+":latest"))
|
2019-09-09 21:07:46 +00:00
|
|
|
assert.Assert(c, !strings.Contains(out, "Loaded image ID:"))
|
2016-05-26 01:25:12 +00:00
|
|
|
}
|