@@ -2,6 +2,8 @@ package daemon
22
33import (
44 "fmt"
5+ "os"
6+ "path/filepath"
57
68 "github.com/docker/docker/runconfig"
79)
@@ -15,6 +17,22 @@ func (daemon *Daemon) ContainerCheckpoint(name string, opts *runconfig.CriuConfi
1517 if ! container .IsRunning () {
1618 return fmt .Errorf ("Container %s not running" , name )
1719 }
20+
21+ if opts .ImagesDirectory == "" {
22+ // By default, images will be stored in /var/lib/docker/execdriver
23+ opts .ImagesDirectory = filepath .Join (daemon .root , "execdriver" , container .daemon .configStore .ExecDriver , container .ID , "criu.image" )
24+ if err := os .MkdirAll (opts .ImagesDirectory , 0755 ); err != nil && ! os .IsExist (err ) {
25+ return err
26+ }
27+ }
28+
29+ if opts .WorkDirectory == "" {
30+ opts .WorkDirectory = filepath .Join (daemon .root , "execdriver" , container .daemon .configStore .ExecDriver , container .ID , "criu.work" )
31+ if err := os .MkdirAll (opts .WorkDirectory , 0755 ); err != nil && ! os .IsExist (err ) {
32+ return err
33+ }
34+ }
35+
1836 if err := container .Checkpoint (opts ); err != nil {
1937 return fmt .Errorf ("Cannot checkpoint container %s: %s" , name , err )
2038 }
@@ -46,6 +64,14 @@ func (daemon *Daemon) ContainerRestore(name string, opts *runconfig.CriuConfig,
4664 }
4765 }
4866
67+ if opts .ImagesDirectory == "" {
68+ opts .ImagesDirectory = filepath .Join (daemon .root , "execdriver" , container .daemon .configStore .ExecDriver , container .ID , "criu.image" )
69+ }
70+
71+ if opts .WorkDirectory == "" {
72+ opts .WorkDirectory = filepath .Join (daemon .root , "execdriver" , container .daemon .configStore .ExecDriver , container .ID , "criu.work" )
73+ }
74+
4975 if err = container .Restore (opts , forceRestore ); err != nil {
5076 container .logEvent ("die" )
5177 return fmt .Errorf ("Cannot restore container %s: %s" , name , err )
0 commit comments