|
@@ -6960,3 +6960,28 @@ func (s *DockerSuite) TestBuildShellWindowsPowershell(c *check.C) {
|
|
|
c.Fatalf("Line with 'John' not found in output %q", out)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// #22868. Make sure shell-form CMD is marked as escaped in the config of the image
|
|
|
+func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *check.C) {
|
|
|
+ testRequires(c, DaemonIsWindows)
|
|
|
+ name := "testbuildcmdshellescaped"
|
|
|
+
|
|
|
+ _, err := buildImage(name, `
|
|
|
+ FROM `+minimalBaseImage()+`
|
|
|
+ CMD "tasklist"
|
|
|
+ `, true)
|
|
|
+ if err != nil {
|
|
|
+ c.Fatal(err)
|
|
|
+ }
|
|
|
+ res := inspectFieldJSON(c, name, "Config.ArgsEscaped")
|
|
|
+ if res != "true" {
|
|
|
+ c.Fatalf("CMD did not update Config.ArgsEscaped on image: %v", res)
|
|
|
+ }
|
|
|
+ dockerCmd(c, "run", "--name", "inspectme", name)
|
|
|
+ dockerCmd(c, "wait", "inspectme")
|
|
|
+ res = inspectFieldJSON(c, name, "Config.Cmd")
|
|
|
+
|
|
|
+ if res != `["cmd","/S","/C","\"tasklist\""]` {
|
|
|
+ c.Fatalf("CMD was not escaped Config.Cmd: got %v", res)
|
|
|
+ }
|
|
|
+}
|