mirror of https://github.com/docker/docs.git
Remove run from non-running commmands
This commit is contained in:
parent
d0084ce5f2
commit
f5fe3ce34e
22
buildfile.go
22
buildfile.go
|
@ -222,16 +222,12 @@ func (b *buildFile) CmdAdd(args string) error {
|
||||||
b.config.Cmd = []string{"/bin/sh", "-c", fmt.Sprintf("#(nop) ADD %s in %s", orig, dest)}
|
b.config.Cmd = []string{"/bin/sh", "-c", fmt.Sprintf("#(nop) ADD %s in %s", orig, dest)}
|
||||||
|
|
||||||
// Create the container and start it
|
// Create the container and start it
|
||||||
c, err := b.builder.Create(b.config)
|
container, err := b.builder.Create(b.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
b.tmpContainers[c.ID] = struct{}{}
|
b.tmpContainers[container.ID] = struct{}{}
|
||||||
|
|
||||||
container := b.runtime.Get(c.ID)
|
|
||||||
if container == nil {
|
|
||||||
return fmt.Errorf("Error while creating the container (CmdAdd)")
|
|
||||||
}
|
|
||||||
if err := container.EnsureMounted(); err != nil {
|
if err := container.EnsureMounted(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -247,7 +243,7 @@ func (b *buildFile) CmdAdd(args string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := b.commit(c.ID, cmd, fmt.Sprintf("ADD %s in %s", orig, dest)); err != nil {
|
if err := b.commit(container.ID, cmd, fmt.Sprintf("ADD %s in %s", orig, dest)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
b.config.Cmd = cmd
|
b.config.Cmd = cmd
|
||||||
|
@ -266,6 +262,7 @@ func (b *buildFile) run() (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
b.tmpContainers[c.ID] = struct{}{}
|
b.tmpContainers[c.ID] = struct{}{}
|
||||||
|
fmt.Fprintf(b.out, "## %s\n", c.ID)
|
||||||
|
|
||||||
//start the container
|
//start the container
|
||||||
if err := c.Start(); err != nil {
|
if err := c.Start(); err != nil {
|
||||||
|
@ -301,11 +298,16 @@ func (b *buildFile) commit(id string, autoCmd []string, comment string) error {
|
||||||
utils.Debugf("[BUILDER] Cache miss")
|
utils.Debugf("[BUILDER] Cache miss")
|
||||||
}
|
}
|
||||||
|
|
||||||
cid, err := b.run()
|
container, err := b.builder.Create(b.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
id = cid
|
b.tmpContainers[container.ID] = struct{}{}
|
||||||
|
id = container.ID
|
||||||
|
if err := container.EnsureMounted(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer container.Unmount()
|
||||||
}
|
}
|
||||||
|
|
||||||
container := b.runtime.Get(id)
|
container := b.runtime.Get(id)
|
||||||
|
@ -374,7 +376,7 @@ func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) {
|
||||||
fmt.Fprintf(b.out, "===> %v\n", b.image)
|
fmt.Fprintf(b.out, "===> %v\n", b.image)
|
||||||
}
|
}
|
||||||
if b.image != "" {
|
if b.image != "" {
|
||||||
fmt.Fprintf(b.out, "Build successful.\n===> %s\n", b.image)
|
fmt.Fprintf(b.out, "Build successful.\n%s\n", b.image)
|
||||||
return b.image, nil
|
return b.image, nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("An error occured during the build\n")
|
return "", fmt.Errorf("An error occured during the build\n")
|
||||||
|
|
Loading…
Reference in New Issue