|
@@ -18,6 +18,7 @@ import (
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
"github.com/docker/docker/api"
|
|
|
+ "github.com/docker/docker/api/types"
|
|
|
"github.com/docker/docker/api/types/container"
|
|
|
"github.com/docker/docker/api/types/strslice"
|
|
|
"github.com/docker/docker/builder"
|
|
@@ -279,12 +280,26 @@ func workdir(b *Builder, args []string, attributes map[string]bool, original str
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- // NOTE: You won't find the "mkdir" for the directory in here. Rather we
|
|
|
- // just set the value in the image's runConfig.WorkingDir property
|
|
|
- // and container.SetupWorkingDirectory() will create it automatically
|
|
|
- // for us the next time the image is used to create a container.
|
|
|
+ // For performance reasons, we explicitly do a create/mkdir now
|
|
|
+ // This avoids having an unnecessary expensive mount/unmount calls
|
|
|
+ // (on Windows in particular) during each container create.
|
|
|
+ // Prior to 1.13, the mkdir was deferred and not executed at this step.
|
|
|
+ if b.disableCommit {
|
|
|
+ // Don't call back into the daemon if we're going through docker commit --change "WORKDIR /foo".
|
|
|
+ // We've already updated the runConfig and that's enough.
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ b.runConfig.Image = b.image
|
|
|
+ container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{Config: b.runConfig}, true)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ b.tmpContainers[container.ID] = struct{}{}
|
|
|
+ if err := b.docker.ContainerCreateWorkdir(container.ID); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
|
|
|
- return b.commit("", b.runConfig.Cmd, fmt.Sprintf("WORKDIR %v", b.runConfig.WorkingDir))
|
|
|
+ return b.commit(container.ID, b.runConfig.Cmd, "WORKDIR "+b.runConfig.WorkingDir)
|
|
|
}
|
|
|
|
|
|
// RUN some command yo
|