'docker run' accepts layer names (it will look up the most recently added layer of that name)

This commit is contained in:
Solomon Hykes 2013-01-20 15:54:21 -08:00
Родитель bf46593505
Коммит 4c5eb22cb2
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -211,8 +211,13 @@ func (docker *Docker) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...stri
BytesChanged: uint(rand.Int31n(24 * 1024 * 1024)), BytesChanged: uint(rand.Int31n(24 * 1024 * 1024)),
} }
for _, name := range *fl_layers { for _, name := range *fl_layers {
// 1: look for layer by ID
if layer, exists := docker.layers[name]; !exists { if layer, exists := docker.layers[name]; !exists {
if srcContainer, exists := docker.containers[name]; exists { // 2: look for a layer by name (and pick the most recent)
if layers, exists := docker.layersByName[name]; exists {
container.Layers = append(container.Layers, *(*layers)[0])
// 3: look for container by name (and copy its layers)
} else if srcContainer, exists := docker.containers[name]; exists {
for _, layer := range srcContainer.Layers { for _, layer := range srcContainer.Layers {
container.Layers = append(container.Layers, layer) container.Layers = append(container.Layers, layer)
} }