Set OS on scratch image and prevent panic if empty

Signed-off-by: John Stephens <johnstep@docker.com>
Upstream-commit: a97817b673cbd3bfaf6e752282c4992ac43ff594
Component: engine
This commit is contained in:
John Stephens
2017-11-06 18:22:15 -08:00
parent ae808b0eb3
commit 7cfb40e0bf
3 changed files with 39 additions and 2 deletions
@@ -619,6 +619,28 @@ func testBuildWithSession(c *check.C, dir, dockerfile string) (outStr string) {
return
}
func (s *DockerSuite) TestBuildScratchCopy(c *check.C) {
testRequires(c, DaemonIsLinux)
dockerfile := `FROM scratch
ADD Dockerfile /
ENV foo bar`
ctx := fakecontext.New(c, "",
fakecontext.WithDockerfile(dockerfile),
)
defer ctx.Close()
res, body, err := request.Post(
"/build",
request.RawContent(ctx.AsTarReader(c)),
request.ContentType("application/x-tar"))
c.Assert(err, checker.IsNil)
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
out, err := request.ReadBody(body)
require.NoError(c, err)
assert.Contains(c, string(out), "Successfully built")
}
type buildLine struct {
Stream string
Aux struct {