commit
28a9ff7f25
21
buildfile.go
21
buildfile.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/archive"
|
"github.com/dotcloud/docker/archive"
|
||||||
|
"github.com/dotcloud/docker/nat"
|
||||||
"github.com/dotcloud/docker/registry"
|
"github.com/dotcloud/docker/registry"
|
||||||
"github.com/dotcloud/docker/runconfig"
|
"github.com/dotcloud/docker/runconfig"
|
||||||
"github.com/dotcloud/docker/runtime"
|
"github.com/dotcloud/docker/runtime"
|
||||||
|
@ -304,8 +305,22 @@ func (b *buildFile) CmdEntrypoint(args string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *buildFile) CmdExpose(args string) error {
|
func (b *buildFile) CmdExpose(args string) error {
|
||||||
ports := strings.Split(args, " ")
|
portsTab := strings.Split(args, " ")
|
||||||
b.config.PortSpecs = append(ports, b.config.PortSpecs...)
|
|
||||||
|
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))
|
return b.commit("", b.config.Cmd, fmt.Sprintf("EXPOSE %v", ports))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,12 +701,12 @@ func (b *buildFile) commit(id string, autoCmd []string, comment string) error {
|
||||||
b.tmpContainers[container.ID] = struct{}{}
|
b.tmpContainers[container.ID] = struct{}{}
|
||||||
fmt.Fprintf(b.outStream, " ---> Running in %s\n", utils.TruncateID(container.ID))
|
fmt.Fprintf(b.outStream, " ---> Running in %s\n", utils.TruncateID(container.ID))
|
||||||
id = container.ID
|
id = container.ID
|
||||||
|
|
||||||
if err := container.Mount(); err != nil {
|
if err := container.Mount(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer container.Unmount()
|
defer container.Unmount()
|
||||||
}
|
}
|
||||||
|
|
||||||
container := b.runtime.Get(id)
|
container := b.runtime.Get(id)
|
||||||
if container == nil {
|
if container == nil {
|
||||||
return fmt.Errorf("An error occured while creating the container")
|
return fmt.Errorf("An error occured while creating the container")
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/dotcloud/docker/archive"
|
"github.com/dotcloud/docker/archive"
|
||||||
"github.com/dotcloud/docker/engine"
|
"github.com/dotcloud/docker/engine"
|
||||||
"github.com/dotcloud/docker/image"
|
"github.com/dotcloud/docker/image"
|
||||||
|
"github.com/dotcloud/docker/nat"
|
||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
@ -492,7 +493,7 @@ func TestBuildExpose(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if img.Config.PortSpecs[0] != "4243" {
|
if _, exists := img.Config.ExposedPorts[nat.NewPort("tcp", "4243")]; !exists {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -594,6 +595,17 @@ func TestBuildImageWithCache(t *testing.T) {
|
||||||
checkCacheBehavior(t, template, true)
|
checkCacheBehavior(t, template, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBuildExposeWithCache(t *testing.T) {
|
||||||
|
template := testContextTemplate{`
|
||||||
|
from {IMAGE}
|
||||||
|
maintainer dockerio
|
||||||
|
expose 80
|
||||||
|
run echo hello
|
||||||
|
`,
|
||||||
|
nil, nil}
|
||||||
|
checkCacheBehavior(t, template, true)
|
||||||
|
}
|
||||||
|
|
||||||
func TestBuildImageWithoutCache(t *testing.T) {
|
func TestBuildImageWithoutCache(t *testing.T) {
|
||||||
template := testContextTemplate{`
|
template := testContextTemplate{`
|
||||||
from {IMAGE}
|
from {IMAGE}
|
||||||
|
@ -877,7 +889,7 @@ func TestBuildInheritance(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// from parent
|
// from parent
|
||||||
if img.Config.PortSpecs[0] != "4243" {
|
if _, exists := img.Config.ExposedPorts[nat.NewPort("tcp", "4243")]; !exists {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ func Merge(userConf, imageConf *Config) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !userConf.Tty {
|
if !userConf.Tty {
|
||||||
userConf.Tty = imageConf.Tty
|
userConf.Tty = imageConf.Tty
|
||||||
}
|
}
|
||||||
|
|
|
@ -534,7 +534,6 @@ func (runtime *Runtime) Create(config *runconfig.Config, name string) (*Containe
|
||||||
// The image can optionally be tagged into a repository
|
// 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) {
|
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: freeze the container before copying it to avoid data corruption?
|
||||||
// FIXME: this shouldn't be in commands.
|
|
||||||
if err := container.Mount(); err != nil {
|
if err := container.Mount(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1970,7 +1970,6 @@ func (srv *Server) canDeleteImage(imgID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) ImageGetCached(imgID string, config *runconfig.Config) (*image.Image, error) {
|
func (srv *Server) ImageGetCached(imgID string, config *runconfig.Config) (*image.Image, error) {
|
||||||
|
|
||||||
// Retrieve all images
|
// Retrieve all images
|
||||||
images, err := srv.runtime.Graph().Map()
|
images, err := srv.runtime.Graph().Map()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue