mirror of https://github.com/docker/docs.git
Function to list image data.
This commit is contained in:
parent
32b14b5335
commit
8f0dc52325
|
@ -28,7 +28,7 @@ Docker.removeContainer = function (containerId, callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Docker.listContainers = function (callback) {
|
Docker.listContainers = function (callback) {
|
||||||
docker.listContainers(function (err, containers) {
|
docker.listContainers({all: true}, function (err, containers) {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -168,12 +168,42 @@ Docker.getImageData = function (imageId, callback) {
|
||||||
image.inspect(function (err, data) {
|
image.inspect(function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
data.Config.Volumes = convertVolumeObjToArray(data.Config.Volumes);
|
if (data.Config && data.Config.Volumes) {
|
||||||
data.ContainerConfig.Volumes = convertVolumeObjToArray(data.ContainerConfig.Volumes);
|
data.Config.Volumes = convertVolumeObjToArray(data.Config.Volumes);
|
||||||
|
}
|
||||||
|
if (data.ContainerConfig && data.ContainerConfig.Volumes) {
|
||||||
|
data.ContainerConfig.Volumes = convertVolumeObjToArray(data.ContainerConfig.Volumes);
|
||||||
|
}
|
||||||
callback(null, data);
|
callback(null, data);
|
||||||
return;
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Docker.listImages = function (callback) {
|
||||||
|
docker.listImages({all: false}, function (err, images) {
|
||||||
|
if (err) {
|
||||||
|
callback(err, null);
|
||||||
|
} else {
|
||||||
|
var cbList = _.map(images, function (image) {
|
||||||
|
return function (cb) {
|
||||||
|
Docker.getImageData(image.Id, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
cb(err, null);
|
||||||
|
} else {
|
||||||
|
var mergedData = _.extend(image, data);
|
||||||
|
cb(null, mergedData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
async.parallel(cbList, function (err, results) {
|
||||||
|
if (err) {
|
||||||
|
callback(err, null);
|
||||||
|
} else {
|
||||||
|
callback(null, results);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue