Add default PATH to 'scratch' images

Closes #19012

Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: d3ea7e80e879b506bddffd51c3ab65b8078a34f4
Component: engine
This commit is contained in:
Doug Davis
2016-01-03 19:45:06 -08:00
parent 289db2e235
commit 69f0af2128
3 changed files with 72 additions and 22 deletions

View File

@ -2143,6 +2143,39 @@ func (s *DockerSuite) TestBuildEnv(c *check.C) {
}
}
func (s *DockerSuite) TestBuildPATH(c *check.C) {
testRequires(c, DaemonIsLinux)
defPath := "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
fn := func(dockerfile string, exp string) {
_, err := buildImage("testbldpath", dockerfile, true)
c.Assert(err, check.IsNil)
res, err := inspectField("testbldpath", "Config.Env")
c.Assert(err, check.IsNil)
if res != exp {
c.Fatalf("Env %q, expected %q for dockerfile:%q", res, exp, dockerfile)
}
}
tests := []struct{ dockerfile, exp string }{
{"FROM scratch\nMAINTAINER me", "[PATH=" + defPath + "]"},
{"FROM busybox\nMAINTAINER me", "[PATH=" + defPath + "]"},
{"FROM scratch\nENV FOO=bar", "[PATH=" + defPath + " FOO=bar]"},
{"FROM busybox\nENV FOO=bar", "[PATH=" + defPath + " FOO=bar]"},
{"FROM scratch\nENV PATH=/test", "[PATH=/test]"},
{"FROM busybox\nENV PATH=/test", "[PATH=/test]"},
{"FROM scratch\nENV PATH=''", "[PATH=]"},
{"FROM busybox\nENV PATH=''", "[PATH=]"},
}
for _, test := range tests {
fn(test.dockerfile, test.exp)
}
}
func (s *DockerSuite) TestBuildContextCleanup(c *check.C) {
testRequires(c, DaemonIsLinux)
testRequires(c, SameHostDaemon)