Fix docker.getBinds()

This commit is contained in:
Girish Ramakrishnan
2020-10-29 11:47:37 -07:00
parent f8d6fd80d5
commit fa4392df09

View File

@@ -190,22 +190,22 @@ function getBinds(app, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof callback, 'function');
if (!app.volumes || app.volumes.length === 0) return callback(null);
if (app.mounts.length === 0) return callback(null);
let binds = [];
volumes.list(function (error, result) {
if (error) return callback(error);
let volumesById = {};
result.forEach(r => volumesById[r.id] = r);
for (const volume of result) {
const appVolume = app.volumes.find(v => v.id === volume.id);
if (!appVolume) continue;
binds.push(`${volume.hostPath}:/media/${volume.name}:${appVolume.readOnly ? 'ro' : 'rw'}`);
for (const mount of app.mounts) {
const volume = volumesById[mount.volumeId];
binds.push(`${volume.hostPath}:/media/${volume.name}:${mount.readOnly ? 'ro' : 'rw'}`);
}
});
return binds;
callback(null, binds);
});
}
function createSubcontainer(app, name, cmd, options, callback) {