|
@@ -2459,3 +2459,95 @@ func TestBuildIgnoreInvalidInstruction(t *testing.T) {
|
|
|
|
|
|
logDone("build - ignore invalid Dockerfile instruction")
|
|
logDone("build - ignore invalid Dockerfile instruction")
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func TestBuildEntrypointInheritance(t *testing.T) {
|
|
|
|
+ defer deleteImages("parent", "child")
|
|
|
|
+
|
|
|
|
+ if _, err := buildImage("parent", `
|
|
|
|
+ FROM busybox
|
|
|
|
+ ENTRYPOINT exit 130
|
|
|
|
+ `, true); err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ status, _ := runCommand(exec.Command(dockerBinary, "run", "parent"))
|
|
|
|
+
|
|
|
|
+ if status != 130 {
|
|
|
|
+ t.Fatalf("expected exit code 130 but received %d", status)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if _, err := buildImage("child", `
|
|
|
|
+ FROM parent
|
|
|
|
+ ENTRYPOINT exit 5
|
|
|
|
+ `, true); err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ status, _ = runCommand(exec.Command(dockerBinary, "run", "child"))
|
|
|
|
+
|
|
|
|
+ if status != 5 {
|
|
|
|
+ t.Fatal("expected exit code 5 but received %d", status)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ logDone("build - clear entrypoint")
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func TestBuildEntrypointInheritanceInspect(t *testing.T) {
|
|
|
|
+ var (
|
|
|
|
+ name = "testbuildepinherit"
|
|
|
|
+ name2 = "testbuildepinherit2"
|
|
|
|
+ expected = `["/bin/sh","-c","echo quux"]`
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ defer deleteImages(name, name2)
|
|
|
|
+
|
|
|
|
+ if _, err := buildImage(name, "FROM busybox\nENTRYPOINT /foo/bar", true); err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if _, err := buildImage(name2, fmt.Sprintf("FROM %s\nENTRYPOINT echo quux", name), true); err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ res, err := inspectFieldJSON(name2, "Config.Entrypoint")
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err, res)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if res != expected {
|
|
|
|
+ t.Fatalf("Expected value %s not in Config.Entrypoint: %s", expected, res)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "-t", name2))
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err, out)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ expected = "quux"
|
|
|
|
+
|
|
|
|
+ if strings.TrimSpace(out) != expected {
|
|
|
|
+ t.Fatalf("Expected output is %s, got %s", expected, out)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ logDone("build - entrypoint override inheritance properly")
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func TestBuildRunShEntrypoint(t *testing.T) {
|
|
|
|
+ name := "testbuildentrypoint"
|
|
|
|
+ defer deleteImages(name)
|
|
|
|
+ _, err := buildImage(name,
|
|
|
|
+ `FROM busybox
|
|
|
|
+ ENTRYPOINT /bin/echo`,
|
|
|
|
+ true)
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", name))
|
|
|
|
+
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err, out)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ logDone("build - entrypoint with /bin/echo running successfully")
|
|
|
|
+}
|