@@ -35,10 +35,14 @@ import (
3535// NewContainer creates a new container
3636func NewContainer (ctx gocontext.Context , client * containerd.Client , context * cli.Context ) (containerd.Container , error ) {
3737 var (
38- ref = context .Args ().First ()
39- id = context .Args ().Get (1 )
40- args = context .Args ()[2 :]
38+ id string
39+ config = context .IsSet ("config" )
4140 )
41+ if config {
42+ id = context .Args ().First ()
43+ } else {
44+ id = context .Args ().Get (1 )
45+ }
4246
4347 if raw := context .String ("checkpoint" ); raw != "" {
4448 im , err := client .GetImage (ctx , raw )
@@ -54,9 +58,14 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
5458 spec containerd.NewContainerOpts
5559 )
5660
57- if context . IsSet ( " config" ) {
61+ if config {
5862 opts = append (opts , oci .WithSpecFromFile (context .String ("config" )))
5963 } else {
64+ var (
65+ ref = context .Args ().First ()
66+ //for container's id is Args[1]
67+ args = context .Args ()[2 :]
68+ )
6069 opts = append (opts , oci .WithDefaultSpec (), oci .WithDefaultUnixDevices )
6170 opts = append (opts , oci .WithEnv (context .StringSlice ("env" )))
6271 opts = append (opts , withMounts (context ))
0 commit comments