Skip to content

Commit

Permalink
Fix EXPOSE cache miss issue
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <[email protected]> (github: creack)
  • Loading branch information
creack committed Mar 13, 2014
1 parent 6ac6619 commit ab26c16
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
21 changes: 18 additions & 3 deletions buildfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"github.com/dotcloud/docker/archive"
"github.com/dotcloud/docker/nat"
"github.com/dotcloud/docker/registry"
"github.com/dotcloud/docker/runconfig"
"github.com/dotcloud/docker/runtime"
Expand Down Expand Up @@ -304,8 +305,22 @@ func (b *buildFile) CmdEntrypoint(args string) error {
}

func (b *buildFile) CmdExpose(args string) error {
ports := strings.Split(args, " ")
b.config.PortSpecs = append(ports, b.config.PortSpecs...)
portsTab := strings.Split(args, " ")

if b.config.ExposedPorts == nil {
b.config.ExposedPorts = make(nat.PortSet)
}
ports, _, err := nat.ParsePortSpecs(append(portsTab, b.config.PortSpecs...))
if err != nil {
return err
}
for port := range ports {
if _, exists := b.config.ExposedPorts[port]; !exists {
b.config.ExposedPorts[port] = struct{}{}
}
}
b.config.PortSpecs = nil

return b.commit("", b.config.Cmd, fmt.Sprintf("EXPOSE %v", ports))
}

Expand Down Expand Up @@ -686,12 +701,12 @@ func (b *buildFile) commit(id string, autoCmd []string, comment string) error {
b.tmpContainers[container.ID] = struct{}{}
fmt.Fprintf(b.outStream, " ---> Running in %s\n", utils.TruncateID(container.ID))
id = container.ID

if err := container.Mount(); err != nil {
return err
}
defer container.Unmount()
}

container := b.runtime.Get(id)
if container == nil {
return fmt.Errorf("An error occured while creating the container")
Expand Down
1 change: 1 addition & 0 deletions runconfig/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func Merge(userConf, imageConf *Config) error {
}
}
}

if !userConf.Tty {
userConf.Tty = imageConf.Tty
}
Expand Down
1 change: 0 additions & 1 deletion runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ func (runtime *Runtime) Create(config *runconfig.Config, name string) (*Containe
// The image can optionally be tagged into a repository
func (runtime *Runtime) Commit(container *Container, repository, tag, comment, author string, config *runconfig.Config) (*image.Image, error) {
// FIXME: freeze the container before copying it to avoid data corruption?
// FIXME: this shouldn't be in commands.
if err := container.Mount(); err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,6 @@ func (srv *Server) canDeleteImage(imgID string) error {
}

func (srv *Server) ImageGetCached(imgID string, config *runconfig.Config) (*image.Image, error) {

// Retrieve all images
images, err := srv.runtime.Graph().Map()
if err != nil {
Expand Down

0 comments on commit ab26c16

Please sign in to comment.