Browse code

Generate an error on unknown Dockerfile instruction

Instead of just printing a warning and going on, this will generate
an error and stop processing.

This used to be part of #10561 but I decided it might need its own
independent discussion/PR as to not derail #10561.

Signed-off-by: Doug Davis <dug@us.ibm.com>

Doug Davis authored on 2015/02/06 00:23:25
Showing 3 changed files
... ...
@@ -309,7 +309,5 @@ func (b *Builder) dispatch(stepN int, ast *parser.Node) error {
309 309
 		return f(b, strList, attrs, original)
310 310
 	}
311 311
 
312
-	fmt.Fprintf(b.ErrStream, "# Skipping unknown instruction %s\n", strings.ToUpper(cmd))
313
-
314
-	return nil
312
+	return fmt.Errorf("Unknown instruction: %s", strings.ToUpper(cmd))
315 313
 }
... ...
@@ -15,6 +15,9 @@ For a complete list of patches, fixes, and other improvements, see the
15 15
 
16 16
 *New Features*
17 17
 
18
+* [1.6] The Docker daemon will no longer ignore unknown commands
19
+  while processing a `Dockerfile`. Instead it will generate an error and halt
20
+  processing.
18 21
 * The Docker daemon has now supports for IPv6 networking between containers
19 22
   and on the `docker0` bridge. For more information see the
20 23
   [IPv6 networking reference](/articles/networking/#ipv6).
... ...
@@ -22,7 +25,7 @@ For a complete list of patches, fixes, and other improvements, see the
22 22
   container to writing to volumes [PR# 10093](https://github.com/docker/docker/pull/10093).
23 23
 * A new `docker stats CONTAINERID` command has been added to allow users to view a
24 24
   continuously updating stream of container resource usage statistics. See the
25
-  [`stats` command line reference](/reference/commandline/cli/#stats) and the 
25
+  [`stats` command line reference](/reference/commandline/cli/#stats) and the
26 26
   [container `stats` API reference](/reference/api/docker_remote_api_v1.17/#get-container-stats-based-on-resource-usage).
27 27
   **Note**: this feature is only enabled for the `libcontainer` exec-driver at this point.
28 28
 * Users can now specify the file to use as the `Dockerfile` by running
... ...
@@ -4343,16 +4343,16 @@ func TestBuildCmdJSONNoShDashC(t *testing.T) {
4343 4343
 	logDone("build - cmd should not have /bin/sh -c for json")
4344 4344
 }
4345 4345
 
4346
-func TestBuildIgnoreInvalidInstruction(t *testing.T) {
4346
+func TestBuildErrorInvalidInstruction(t *testing.T) {
4347 4347
 	name := "testbuildignoreinvalidinstruction"
4348 4348
 	defer deleteImages(name)
4349 4349
 
4350 4350
 	out, _, err := buildImageWithOut(name, "FROM busybox\nfoo bar", true)
4351
-	if err != nil {
4352
-		t.Fatal(err, out)
4351
+	if err == nil {
4352
+		t.Fatalf("Should have failed: %s", out)
4353 4353
 	}
4354 4354
 
4355
-	logDone("build - ignore invalid Dockerfile instruction")
4355
+	logDone("build - error invalid Dockerfile instruction")
4356 4356
 }
4357 4357
 
4358 4358
 func TestBuildEntrypointInheritance(t *testing.T) {