mirror of https://github.com/docker/docs.git
Implement the CMD instruction in order to allow autorun
This commit is contained in:
parent
a64ebe5feb
commit
db4417b601
31
builder.go
31
builder.go
|
@ -2,6 +2,7 @@ package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -311,6 +312,35 @@ func (builder *Builder) Build(dockerfile io.Reader, stdout io.Writer) (*Image, e
|
||||||
// use the base as the new image
|
// use the base as the new image
|
||||||
image = base
|
image = base
|
||||||
|
|
||||||
|
break
|
||||||
|
case "cmd":
|
||||||
|
fmt.Fprintf(stdout, "CMD %s\n", arguments)
|
||||||
|
|
||||||
|
// 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{}{}
|
||||||
|
|
||||||
|
cmd := []string{}
|
||||||
|
if err := json.Unmarshal([]byte(arguments), &cmd); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
config.Cmd = cmd
|
||||||
|
|
||||||
|
// Commit the container
|
||||||
|
base, err = builder.Commit(c, "", "", "", maintainer, config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tmpImages[base.Id] = struct{}{}
|
||||||
|
|
||||||
|
fmt.Fprintf(stdout, "===> %s\n", base.ShortId())
|
||||||
|
image = base
|
||||||
break
|
break
|
||||||
case "expose":
|
case "expose":
|
||||||
ports := strings.Split(arguments, " ")
|
ports := strings.Split(arguments, " ")
|
||||||
|
@ -340,7 +370,6 @@ func (builder *Builder) Build(dockerfile io.Reader, stdout io.Writer) (*Image, e
|
||||||
tmpImages[base.Id] = struct{}{}
|
tmpImages[base.Id] = struct{}{}
|
||||||
|
|
||||||
fmt.Fprintf(stdout, "===> %s\n", base.ShortId())
|
fmt.Fprintf(stdout, "===> %s\n", base.ShortId())
|
||||||
|
|
||||||
image = base
|
image = base
|
||||||
break
|
break
|
||||||
case "insert":
|
case "insert":
|
||||||
|
|
Loading…
Reference in New Issue