mirror of https://github.com/docker/docs.git
use a symlink instead of a copy
This commit is contained in:
parent
31638ab2ad
commit
f9901ead06
22
runtime.go
22
runtime.go
|
@ -582,7 +582,7 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := copyLxcStart(config.Root); err != nil {
|
if err := linkLxcStart(config.Root); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
g, err := NewGraph(path.Join(config.Root, "graph"))
|
g, err := NewGraph(path.Join(config.Root, "graph"))
|
||||||
|
@ -647,25 +647,21 @@ func (runtime *Runtime) Close() error {
|
||||||
return runtime.containerGraph.Close()
|
return runtime.containerGraph.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyLxcStart(root string) error {
|
func linkLxcStart(root string) error {
|
||||||
sourcePath, err := exec.LookPath("lxc-start")
|
sourcePath, err := exec.LookPath("lxc-start")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
targetPath := path.Join(root, "lxc-start-unconfined")
|
targetPath := path.Join(root, "lxc-start-unconfined")
|
||||||
sourceFile, err := os.Open(sourcePath)
|
|
||||||
if err != nil {
|
if _, err := os.Stat(targetPath); err != nil && !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
|
} else if err == nil {
|
||||||
|
if err := os.Remove(targetPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
defer sourceFile.Close()
|
return os.Symlink(sourcePath, targetPath)
|
||||||
targetFile, err := os.Create(targetPath)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer targetFile.Close()
|
|
||||||
os.Chmod(targetPath, 0755)
|
|
||||||
_, err = io.Copy(targetFile, sourceFile)
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// History is a convenience type for storing a list of containers,
|
// History is a convenience type for storing a list of containers,
|
||||||
|
|
Loading…
Reference in New Issue