Add docker.createSubcontainer
This commit is contained in:
@@ -138,7 +138,7 @@ function unconfigureNginx(app, callback) {
|
|||||||
function createContainer(app, callback) {
|
function createContainer(app, callback) {
|
||||||
assert(!app.containerId); // otherwise, it will trigger volumeFrom
|
assert(!app.containerId); // otherwise, it will trigger volumeFrom
|
||||||
|
|
||||||
docker.createContainer(app, null /* command */, function (error, container) {
|
docker.createContainer(app, function (error, container) {
|
||||||
if (error) return callback(new Error('Error creating container: ' + error));
|
if (error) return callback(new Error('Error creating container: ' + error));
|
||||||
|
|
||||||
updateApp(app, { containerId: container.id }, callback);
|
updateApp(app, { containerId: container.id }, callback);
|
||||||
|
|||||||
@@ -114,12 +114,12 @@ function downloadImage(manifest, callback) {
|
|||||||
}, callback);
|
}, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createContainer(app, cmd, callback) {
|
function createSubcontainer(app, cmd, callback) {
|
||||||
assert.strictEqual(typeof app, 'object');
|
assert.strictEqual(typeof app, 'object');
|
||||||
assert(!cmd || util.isArray(cmd));
|
assert(!cmd || util.isArray(cmd));
|
||||||
assert.strictEqual(typeof callback, 'function');
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|
||||||
var docker = exports.connection;
|
var docker = exports.connection, isSubcontainer = !!cmd;
|
||||||
|
|
||||||
var manifest = app.manifest;
|
var manifest = app.manifest;
|
||||||
var exposedPorts = {}, dockerPortBindings = { };
|
var exposedPorts = {}, dockerPortBindings = { };
|
||||||
@@ -165,7 +165,8 @@ function createContainer(app, cmd, callback) {
|
|||||||
},
|
},
|
||||||
Labels: {
|
Labels: {
|
||||||
"location": app.location,
|
"location": app.location,
|
||||||
"appId": app.id
|
"appId": app.id,
|
||||||
|
"isSubcontainer": String(isSubcontainer)
|
||||||
},
|
},
|
||||||
HostConfig: {
|
HostConfig: {
|
||||||
Binds: addons.getBindsSync(app, app.manifest.addons),
|
Binds: addons.getBindsSync(app, app.manifest.addons),
|
||||||
@@ -182,7 +183,7 @@ function createContainer(app, cmd, callback) {
|
|||||||
CpuShares: 512, // relative to 1024 for system processes
|
CpuShares: 512, // relative to 1024 for system processes
|
||||||
SecurityOpt: config.CLOUDRON ? [ "apparmor:docker-cloudron-app" ] : null // profile available only on cloudron
|
SecurityOpt: config.CLOUDRON ? [ "apparmor:docker-cloudron-app" ] : null // profile available only on cloudron
|
||||||
},
|
},
|
||||||
VolumesFrom: app.containerId ? [ app.containerId ] : null
|
VolumesFrom: isSubcontainer ? [ app.containerId ] : []
|
||||||
};
|
};
|
||||||
|
|
||||||
// older versions wanted a writable /var/log
|
// older versions wanted a writable /var/log
|
||||||
@@ -194,6 +195,10 @@ function createContainer(app, cmd, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createContainer(app, callback) {
|
||||||
|
createSubcontainer(app, null, callback);
|
||||||
|
}
|
||||||
|
|
||||||
function startContainer(containerId, callback) {
|
function startContainer(containerId, callback) {
|
||||||
assert.strictEqual(typeof containerId, 'string');
|
assert.strictEqual(typeof containerId, 'string');
|
||||||
assert.strictEqual(typeof callback, 'function');
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|||||||
Reference in New Issue
Block a user