@@ -240,19 +240,14 @@ func runContainer(context *cli.Context, createOnly bool) {
240240 }
241241 }
242242
243- address := filepath .Join (namespace , "namespaced.sock" )
244- err = createContainer (context , container , address , spec )
243+ err = createContainer (context , container , namespace , spec )
245244 if err != nil {
246245 fmt .Fprintf (os .Stderr , "error %v\n " , err )
247246 cmd .Process .Signal (syscall .SIGINT )
248247 os .Exit (- 1 )
249248 }
250- err = os .Symlink (namespace , filepath .Join (root , container , "namespace" ))
251- if err != nil {
252- cmd .Process .Signal (syscall .SIGINT )
253- os .Exit (- 1 )
254- }
255249 if ! createOnly {
250+ address := filepath .Join (namespace , "namespaced.sock" )
256251 startContainer (context , bundle , container , address , spec , context .Bool ("detach" ))
257252 }
258253 os .Exit (0 )
@@ -290,7 +285,8 @@ func checkConsole(context *cli.Context, p *specs.Process, createOnly bool) {
290285// * In runv, shared namespaces multiple containers are located in the same VM which is managed by a runv-daemon.
291286// * Any running container can exit in any arbitrary order, the runv-daemon and the VM are existed until the last container of the VM is existed
292287
293- func createContainer (context * cli.Context , container , address string , config * specs.Spec ) error {
288+ func createContainer (context * cli.Context , container , namespace string , config * specs.Spec ) error {
289+ address := filepath .Join (namespace , "namespaced.sock" )
294290 c := getClient (address )
295291
296292 return ociCreate (context , container , func (stdin , stdout , stderr string ) error {
@@ -306,6 +302,12 @@ func createContainer(context *cli.Context, container, address string, config *sp
306302 if _ , err := c .CreateContainer (netcontext .Background (), r ); err != nil {
307303 return err
308304 }
305+
306+ // create symbol link to namespace file
307+ namespaceDir := filepath .Join (context .GlobalString ("root" ), container , "namespace" )
308+ if err := os .Symlink (namespace , namespaceDir ); err != nil {
309+ return fmt .Errorf ("failed to create symbol link %q: %v" , filepath .Join (namespaceDir , "namespaced.sock" ), err )
310+ }
309311 return nil
310312 })
311313
@@ -355,8 +357,14 @@ func ociCreate(context *cli.Context, container string, createFunc func(stdin, st
355357 if context .String ("pid-file" ) != "" || tty != nil {
356358 args := []string {
357359 "runv" , "--root" , context .GlobalString ("root" ),
358- "shim" , "--container" , container , "--process" , "init" ,
359360 }
361+ if context .GlobalString ("log_dir" ) != "" {
362+ args = append (args , "--log_dir" , filepath .Join (context .GlobalString ("log_dir" ), "shim-" + container ))
363+ }
364+ if context .GlobalBool ("debug" ) {
365+ args = append (args , "--debug" )
366+ }
367+ args = append (args , "shim" , "--container" , container , "--process" , "init" )
360368 if context .String ("pid-file" ) != "" {
361369 args = append (args , "--proxy-exit-code" , "--proxy-signal" )
362370 }
0 commit comments