зеркало из https://github.com/microsoft/docker.git
'docker run' works with paths as well as image IDs
This commit is contained in:
Родитель
8158616d61
Коммит
de50c9c4e8
20
fs/store.go
20
fs/store.go
|
@ -101,6 +101,26 @@ func (store *Store) List(pth string) ([]*Image, error) {
|
||||||
return store.imageList(images), nil
|
return store.imageList(images), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (store *Store) Find(pth string) (*Image, error) {
|
||||||
|
pth = path.Clean(pth)
|
||||||
|
img, err := store.Get(pth)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if img != nil {
|
||||||
|
return img, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
images, err := store.orm.Select(Image{}, "select images.* from images, paths where Path=? and paths.Image=images.Id order by images.Created desc limit 1", pth)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if len(images) < 1 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
img = images[0].(*Image)
|
||||||
|
img.store = store
|
||||||
|
return img, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (store *Store) Get(id string) (*Image, error) {
|
func (store *Store) Get(id string) (*Image, error) {
|
||||||
img, err := store.orm.Get(Image{}, id)
|
img, err := store.orm.Get(Image{}, id)
|
||||||
if img == nil {
|
if img == nil {
|
||||||
|
|
|
@ -835,7 +835,7 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
cmdline = []string{"/bin/bash", "-i"}
|
cmdline = []string{"/bin/bash", "-i"}
|
||||||
}
|
}
|
||||||
// Find the image
|
// Find the image
|
||||||
img, err := srv.images.Get(name)
|
img, err := srv.images.Find(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if img == nil {
|
} else if img == nil {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче