@@ -73,37 +73,41 @@ func (c *config) runtimeSpec(rootfs string) (*specs.Spec, error) {
7373 var s specs.Spec
7474 s .Version = specs .Version
7575 // we should at least apply the default spec, otherwise this is totally useless
76- s .Process .Terminal = true
77- s .Root .Path = rootfs
78- s .Process .Cwd = "/"
79- if c .Config .WorkingDir != "" {
80- s .Process .Cwd = c .Config .WorkingDir
76+ if s .Root != nil {
77+ s .Root .Path = rootfs
8178 }
82- s .Process .Env = append (s .Process .Env , c .Config .Env ... )
83- s .Process .Args = append (s .Process .Args , c .Config .Entrypoint ... )
84- s .Process .Args = append (s .Process .Args , c .Config .Cmd ... )
85-
86- if len (s .Process .Args ) == 0 {
87- s .Process .Args = append (s .Process .Args , "sh" )
88- }
89-
90- if uid , err := strconv .Atoi (c .Config .User ); err == nil {
91- s .Process .User .UID = uint32 (uid )
92- } else if ug := strings .Split (c .Config .User , ":" ); len (ug ) == 2 {
93- uid , err := strconv .Atoi (ug [0 ])
94- if err != nil {
95- return nil , errors .New ("config.User: unsupported uid format" )
79+ if s .Process != nil {
80+ s .Process .Terminal = true
81+ s .Process .Cwd = "/"
82+ if c .Config .WorkingDir != "" {
83+ s .Process .Cwd = c .Config .WorkingDir
9684 }
85+ s .Process .Env = append (s .Process .Env , c .Config .Env ... )
86+ s .Process .Args = append (s .Process .Args , c .Config .Entrypoint ... )
87+ s .Process .Args = append (s .Process .Args , c .Config .Cmd ... )
9788
98- gid , err := strconv .Atoi (ug [1 ])
99- if err != nil {
100- return nil , errors .New ("config.User: unsupported gid format" )
89+ if len (s .Process .Args ) == 0 {
90+ s .Process .Args = append (s .Process .Args , "sh" )
10191 }
10292
103- s .Process .User .UID = uint32 (uid )
104- s .Process .User .GID = uint32 (gid )
105- } else if c .Config .User != "" {
106- return nil , errors .New ("config.User: unsupported format" )
93+ if uid , err := strconv .Atoi (c .Config .User ); err == nil {
94+ s .Process .User .UID = uint32 (uid )
95+ } else if ug := strings .Split (c .Config .User , ":" ); len (ug ) == 2 {
96+ uid , err := strconv .Atoi (ug [0 ])
97+ if err != nil {
98+ return nil , errors .New ("config.User: unsupported uid format" )
99+ }
100+
101+ gid , err := strconv .Atoi (ug [1 ])
102+ if err != nil {
103+ return nil , errors .New ("config.User: unsupported gid format" )
104+ }
105+
106+ s .Process .User .UID = uint32 (uid )
107+ s .Process .User .GID = uint32 (gid )
108+ } else if c .Config .User != "" {
109+ return nil , errors .New ("config.User: unsupported format" )
110+ }
107111 }
108112
109113 s .Linux = & specs.Linux {}
0 commit comments