From ae1e655fb1d95b5828a2b0cd67d19d090d04ff74 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Wed, 1 May 2013 16:26:46 -0700 Subject: [PATCH] Implement EXPOSE to builder --- builder.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/builder.go b/builder.go index 6ab3a6f84e..e49f7d4527 100644 --- a/builder.go +++ b/builder.go @@ -262,6 +262,35 @@ func (builder *Builder) Build(dockerfile io.Reader, stdout io.Writer) (*Image, e // use the base as the new image image = base + break + case "expose": + ports := strings.Split(arguments, " ") + + fmt.Fprintf(stdout, "EXPOSE %v\n", ports) + if image == nil { + return nil, fmt.Errorf("Please provide a source image with `from` prior to copy") + } + + // Create the container and start it + c, err := builder.Create(&Config{Image: image.Id, Cmd: []string{"", ""}}) + if err != nil { + return nil, err + } + if err := c.Start(); err != nil { + return nil, err + } + tmpContainers[c.Id] = struct{}{} + + // Commit the container + base, err = builder.Commit(c, "", "", "", maintainer, &Config{PortSpecs: ports}) + if err != nil { + return nil, err + } + tmpImages[base.Id] = struct{}{} + + fmt.Fprintf(stdout, "===> %s\n", base.ShortId()) + + image = base break case "insert": if image == nil {