Add docker.createSubcontainer

This commit is contained in:
Girish Ramakrishnan
2015-10-19 21:33:53 -07:00
parent 351d7d22fb
commit 15aa4ecc5d
2 changed files with 10 additions and 5 deletions

View File

@@ -138,7 +138,7 @@ function unconfigureNginx(app, callback) {
function createContainer(app, callback) {
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));
updateApp(app, { containerId: container.id }, callback);

View File

@@ -114,12 +114,12 @@ function downloadImage(manifest, callback) {
}, callback);
}
function createContainer(app, cmd, callback) {
function createSubcontainer(app, cmd, callback) {
assert.strictEqual(typeof app, 'object');
assert(!cmd || util.isArray(cmd));
assert.strictEqual(typeof callback, 'function');
var docker = exports.connection;
var docker = exports.connection, isSubcontainer = !!cmd;
var manifest = app.manifest;
var exposedPorts = {}, dockerPortBindings = { };
@@ -165,7 +165,8 @@ function createContainer(app, cmd, callback) {
},
Labels: {
"location": app.location,
"appId": app.id
"appId": app.id,
"isSubcontainer": String(isSubcontainer)
},
HostConfig: {
Binds: addons.getBindsSync(app, app.manifest.addons),
@@ -182,7 +183,7 @@ function createContainer(app, cmd, callback) {
CpuShares: 512, // relative to 1024 for system processes
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
@@ -194,6 +195,10 @@ function createContainer(app, cmd, callback) {
});
}
function createContainer(app, callback) {
createSubcontainer(app, null, callback);
}
function startContainer(containerId, callback) {
assert.strictEqual(typeof containerId, 'string');
assert.strictEqual(typeof callback, 'function');