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

Commit

Permalink
container: fix the issue of missing the entrypoint in cmd
Browse files Browse the repository at this point in the history
Signed-off-by: fupan <[email protected]>
  • Loading branch information
lifupan committed Jul 18, 2018
1 parent 10c4087 commit 2814931
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions daemon/pod/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,14 +614,14 @@ func (c *Container) ociEnv() []string {
return envs
}

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

ocispec = oci.DefaultSpec()
ocispec.Root.Path = ROOTFS
ocispec.Root.Readonly = c.spec.ReadOnly

ocispec.Process.Args = c.spec.Command
ocispec.Process.Args = cmds
ocispec.Process.Env = c.ociEnv()
ocispec.Process.Cwd = c.spec.Workdir
ocispec.Process.Terminal = c.spec.Tty
Expand Down Expand Up @@ -650,6 +650,7 @@ func (c *Container) ociSpec(cjson *dockertypes.ContainerJSON) *specs.Spec {
func (c *Container) containerConfig(cjson *dockertypes.ContainerJSON) (*vc.ContainerConfig, error) {
var user, group string
var ociSpec *specs.Spec
var cmds []string

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

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

if len(c.spec.Command) == 0 {
for _, cmd := range cjson.Config.Cmd.Slice() {
c.spec.Command = append(c.spec.Command, cmd)
}
}
cmds = append(cmds, cjson.Config.Entrypoint.Slice()...)
cmds = append(cmds, cjson.Config.Cmd.Slice()...)

ociSpec = c.ociSpec(cjson)
ociSpec = c.ociSpec(cjson, cmds)

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

cmd := vc.Cmd{
Args: c.spec.Command,
Args: cmds,
Envs: c.cmdEnvs([]vc.EnvVar{}),
WorkDir: c.spec.Workdir,
User: user,
Expand Down

0 comments on commit 2814931

Please sign in to comment.