@@ -504,6 +504,7 @@ func (c *Container) createByEngine() (*dockertypes.ContainerJSON, error) {
504504 if len (c .spec .Envs ) != 0 {
505505 envs := []string {}
506506 for _ , env := range c .spec .Envs {
507+
507508 envs = append (envs , env .Env + "=" + env .Value )
508509 }
509510 config .Env = envs
@@ -529,6 +530,19 @@ func (c *Container) createByEngine() (*dockertypes.ContainerJSON, error) {
529530 return nil , err
530531 }
531532
533+ for _ , v := range rsp .Config .Env {
534+ pair := strings .SplitN (v , "=" , 2 )
535+ var env = apitypes.EnvironmentVar {}
536+
537+ if len (pair ) == 2 {
538+ env = apitypes.EnvironmentVar {Env : pair [0 ], Value : pair [1 ]}
539+ } else if len (pair ) == 1 {
540+ env = apitypes.EnvironmentVar {Env : pair [0 ], Value : "" }
541+ }
542+
543+ c .spec .Envs = append (c .spec .Envs , & env )
544+ }
545+
532546 c .spec .Id = ccs .ID
533547 c .updateLogPrefix ()
534548 return rsp , nil
@@ -567,17 +581,13 @@ func containerMounts(cjson *dockertypes.ContainerJSON) []vc.Mount {
567581 return mnts
568582}
569583
570- func (c * Container ) ociEnv (cjson * dockertypes. ContainerJSON ) []string {
584+ func (c * Container ) ociEnv () []string {
571585 var envs []string
572586
573587 for _ , env := range c .spec .Envs {
574588 envs = append (envs , env .Env + "=" + env .Value )
575589 }
576590
577- for _ , env := range cjson .Config .Env {
578- envs = append (envs , env )
579- }
580-
581591 return envs
582592}
583593
@@ -589,7 +599,7 @@ func (c *Container) ociSpec(cjson *dockertypes.ContainerJSON) *specs.Spec {
589599 ocispec .Root .Readonly = c .spec .ReadOnly
590600
591601 ocispec .Process .Args = c .spec .Command
592- ocispec .Process .Env = c .ociEnv (cjson )
602+ ocispec .Process .Env = c .ociEnv ()
593603 ocispec .Process .Cwd = c .spec .Workdir
594604 ocispec .Process .Terminal = c .spec .Tty
595605 /*
0 commit comments