Prechádzať zdrojové kódy

fix entrypoint without cmd

Isao Jonas 12 rokov pred
rodič
commit
0f249c85ea
2 zmenil súbory, kde vykonal 6 pridanie a 2 odobranie
  1. 3 1
      builder.go
  2. 3 1
      buildfile.go

+ 3 - 1
builder.go

@@ -38,7 +38,9 @@ func (builder *Builder) Create(config *Config) (*Container, error) {
 		MergeConfig(config, img.Config)
 	}
 
-	if config.Cmd == nil || len(config.Cmd) == 0 {
+	if len(config.Entrypoint) != 0 && config.Cmd == nil {
+		config.Cmd = []string{}
+	} else if config.Cmd == nil || len(config.Cmd) == 0 {
 		return nil, fmt.Errorf("No command specified")
 	}
 

+ 3 - 1
buildfile.go

@@ -93,6 +93,8 @@ func (b *buildFile) CmdRun(args string) error {
 	b.config.Cmd = nil
 	MergeConfig(b.config, config)
 
+	defer func(cmd []string) { b.config.Cmd = cmd }(cmd)
+
 	utils.Debugf("Command to be executed: %v", b.config.Cmd)
 
 	if b.utilizeCache {
@@ -115,7 +117,7 @@ func (b *buildFile) CmdRun(args string) error {
 	if err := b.commit(cid, cmd, "run"); err != nil {
 		return err
 	}
-	b.config.Cmd = cmd
+
 	return nil
 }