Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 2814931

Browse files
committed
container: fix the issue of missing the entrypoint in cmd
Signed-off-by: fupan <[email protected]>
1 parent 10c4087 commit 2814931

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

daemon/pod/container.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,14 @@ func (c *Container) ociEnv() []string {
614614
return envs
615615
}
616616

617-
func (c *Container) ociSpec(cjson *dockertypes.ContainerJSON) *specs.Spec {
617+
func (c *Container) ociSpec(cjson *dockertypes.ContainerJSON, cmds []string) *specs.Spec {
618618
var ocispec specs.Spec
619619

620620
ocispec = oci.DefaultSpec()
621621
ocispec.Root.Path = ROOTFS
622622
ocispec.Root.Readonly = c.spec.ReadOnly
623623

624-
ocispec.Process.Args = c.spec.Command
624+
ocispec.Process.Args = cmds
625625
ocispec.Process.Env = c.ociEnv()
626626
ocispec.Process.Cwd = c.spec.Workdir
627627
ocispec.Process.Terminal = c.spec.Tty
@@ -650,6 +650,7 @@ func (c *Container) ociSpec(cjson *dockertypes.ContainerJSON) *specs.Spec {
650650
func (c *Container) containerConfig(cjson *dockertypes.ContainerJSON) (*vc.ContainerConfig, error) {
651651
var user, group string
652652
var ociSpec *specs.Spec
653+
var cmds []string
653654

654655
c.Log(TRACE, "container info config %#v, Cmd %v, Args %v", cjson.Config, cjson.Config.Cmd.Slice(), cjson.Args)
655656

@@ -664,13 +665,10 @@ func (c *Container) containerConfig(cjson *dockertypes.ContainerJSON) (*vc.Conta
664665
c.spec.StopSignal = "TERM"
665666
}
666667

667-
if len(c.spec.Command) == 0 {
668-
for _, cmd := range cjson.Config.Cmd.Slice() {
669-
c.spec.Command = append(c.spec.Command, cmd)
670-
}
671-
}
668+
cmds = append(cmds, cjson.Config.Entrypoint.Slice()...)
669+
cmds = append(cmds, cjson.Config.Cmd.Slice()...)
672670

673-
ociSpec = c.ociSpec(cjson)
671+
ociSpec = c.ociSpec(cjson, cmds)
674672

675673
//remove those namespace types from ocispec
676674
for _, ns := range []specs.LinuxNamespaceType{
@@ -714,7 +712,7 @@ func (c *Container) containerConfig(cjson *dockertypes.ContainerJSON) (*vc.Conta
714712
}
715713

716714
cmd := vc.Cmd{
717-
Args: c.spec.Command,
715+
Args: cmds,
718716
Envs: c.cmdEnvs([]vc.EnvVar{}),
719717
WorkDir: c.spec.Workdir,
720718
User: user,

0 commit comments

Comments
 (0)