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

Commit 41df3c1

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

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

daemon/pod/container.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ 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()
@@ -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,13 @@ 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-
}
668+
for _, cmd := range cjson.Config.Entrypoint.Slice() {
669+
cmds = append(cmds, cmd)
671670
}
672671

673-
ociSpec = c.ociSpec(cjson)
672+
cmds = append(cmds, c.spec.Command...)
673+
674+
ociSpec = c.ociSpec(cjson, cmds)
674675

675676
//remove those namespace types from ocispec
676677
for _, ns := range []specs.LinuxNamespaceType{
@@ -714,7 +715,7 @@ func (c *Container) containerConfig(cjson *dockertypes.ContainerJSON) (*vc.Conta
714715
}
715716

716717
cmd := vc.Cmd{
717-
Args: c.spec.Command,
718+
Args: cmds,
718719
Envs: c.cmdEnvs([]vc.EnvVar{}),
719720
WorkDir: c.spec.Workdir,
720721
User: user,

0 commit comments

Comments
 (0)