mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Cleanup Cmd on ENTRYPOINT instruction
Fixes #5147 Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
This commit is contained in:
parent
7dba5024e8
commit
1b6546b840
2 changed files with 43 additions and 2 deletions
|
@ -70,6 +70,9 @@ type buildFile struct {
|
|||
// Deprecated, original writer used for ImagePull. To be removed.
|
||||
outOld io.Writer
|
||||
sf *utils.StreamFormatter
|
||||
|
||||
// cmdSet indicates is CMD was setted in current Dockerfile
|
||||
cmdSet bool
|
||||
}
|
||||
|
||||
func (b *buildFile) clearTmp(containers map[string]struct{}) {
|
||||
|
@ -306,12 +309,17 @@ func (b *buildFile) CmdCmd(args string) error {
|
|||
if err := b.commit("", b.config.Cmd, fmt.Sprintf("CMD %v", cmd)); err != nil {
|
||||
return err
|
||||
}
|
||||
b.cmdSet = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *buildFile) CmdEntrypoint(args string) error {
|
||||
entrypoint := b.buildCmdFromJson(args)
|
||||
b.config.Entrypoint = entrypoint
|
||||
// if there is no cmd in current Dockerfile - cleanup cmd
|
||||
if !b.cmdSet {
|
||||
b.config.Cmd = nil
|
||||
}
|
||||
if err := b.commit("", b.config.Cmd, fmt.Sprintf("ENTRYPOINT %v", entrypoint)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue