integration-cli: improve TestBuildNoNamedVolume

Make sure the error is the one we expected, and slightly clarify
the behavior (named volumes not having a meaning in VOLUME, so will
be used as-is).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-12-03 14:07:45 +01:00
parent 5152c7c3ef
commit 751a6f9f33

View File

@@ -4693,20 +4693,25 @@ func (s *DockerCLIBuildSuite) TestBuildMultiStageUnusedArg(c *testing.T) {
func (s *DockerCLIBuildSuite) TestBuildNoNamedVolume(c *testing.T) {
imgName := strings.ToLower(c.Name())
volName := "testname:/foo"
expError := `ls: /foo/oops: No such file or directory`
if testEnv.DaemonInfo.OSType == "windows" {
volName = "testname:C:\\foo"
expError = `invalid volume specification`
}
cli.DockerCmd(c, "run", "-v", volName, "busybox", "sh", "-c", "touch /foo/oops")
// Named volumes are not supported in VOLUME, so the `<volume-name>:<path>`
// should be used as-is and to be considered a path inside the image.
dockerFile := `FROM busybox
VOLUME ` + volName + `
RUN ls /foo/oops
`
cli.Docker(cli.Args("build", "-t", imgName), build.WithDockerfile(dockerFile)).Assert(c, icmd.Expected{
res := cli.Docker(cli.Args("build", "-t", imgName), build.WithDockerfile(dockerFile)).Assert(c, icmd.Expected{
ExitCode: 1,
})
assert.Check(c, is.Contains(res.Combined(), expError))
}
func (s *DockerCLIBuildSuite) TestBuildTagEvent(c *testing.T) {