mirror of https://github.com/docker/docs.git
Merge pull request #139 from kitematic/jmorgan_fix_app_image_sync
Fixing bugs that occur with sync when containers fail to run
This commit is contained in:
commit
9a92f1cf35
|
@ -14,9 +14,23 @@ AppUtil.run = function (app, callback) {
|
||||||
}});
|
}});
|
||||||
Docker.removeContainer(app.name, function (err) {
|
Docker.removeContainer(app.name, function (err) {
|
||||||
Docker.runContainer(app, image, function (err, container) {
|
Docker.runContainer(app, image, function (err, container) {
|
||||||
if (err) { callback(err); }
|
if (err) {
|
||||||
|
Apps.update(app._id, {$set: {
|
||||||
|
status: 'ERROR',
|
||||||
|
logs: [err.message]
|
||||||
|
}});
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Docker.getContainerData(container.id, function (err, data) {
|
Docker.getContainerData(container.id, function (err, data) {
|
||||||
if (err) { callback(err); }
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
Apps.update(app._id, {$set: {
|
||||||
|
status: 'ERROR',
|
||||||
|
logs: [err.message]
|
||||||
|
}});
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Set a delay for app to spin up
|
// Set a delay for app to spin up
|
||||||
Apps.update(app._id, {$set: {
|
Apps.update(app._id, {$set: {
|
||||||
docker: data,
|
docker: data,
|
||||||
|
@ -153,7 +167,7 @@ AppUtil.sync = function (callback) {
|
||||||
var diffApps = _.difference(guiIds, containerIds);
|
var diffApps = _.difference(guiIds, containerIds);
|
||||||
_.each(diffApps, function (appContainerId) {
|
_.each(diffApps, function (appContainerId) {
|
||||||
var app = Apps.findOne({'docker.Id': appContainerId});
|
var app = Apps.findOne({'docker.Id': appContainerId});
|
||||||
if (app && app.status !== 'STARTING') {
|
if (app && app.status === 'READY') {
|
||||||
AppUtil.remove(app._id);
|
AppUtil.remove(app._id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -211,7 +225,6 @@ AppUtil.sync = function (callback) {
|
||||||
} else {
|
} else {
|
||||||
appObj.volumesEnabled = false;
|
appObj.volumesEnabled = false;
|
||||||
}
|
}
|
||||||
console.log(appObj);
|
|
||||||
Apps.insert(appObj);
|
Apps.insert(appObj);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ Docker.runContainer = function (app, image, callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (app.docker && app.docker.NetworkSettings.Ports) {
|
if (app.docker && app.docker.NetworkSettings && app.docker.NetworkSettings.Ports) {
|
||||||
containerOpts.ExposedPorts = app.docker.NetworkSettings.Ports;
|
containerOpts.ExposedPorts = app.docker.NetworkSettings.Ports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ Docker.runContainer = function (app, image, callback) {
|
||||||
Binds: binds
|
Binds: binds
|
||||||
};
|
};
|
||||||
|
|
||||||
if (app.docker && app.docker.NetworkSettings.Ports) {
|
if (app.docker && app.docker.NetworkSettings && app.docker.NetworkSettings.Ports) {
|
||||||
startOpts.PortBindings = app.docker.NetworkSettings.Ports;
|
startOpts.PortBindings = app.docker.NetworkSettings.Ports;
|
||||||
} else {
|
} else {
|
||||||
startOpts.PublishAllPorts = true;
|
startOpts.PublishAllPorts = true;
|
||||||
|
|
|
@ -259,7 +259,7 @@ ImageUtil.sync = function (callback) {
|
||||||
var diffImages = _.difference(kitematicIds, daemonIds);
|
var diffImages = _.difference(kitematicIds, daemonIds);
|
||||||
_.each(diffImages, function (imageId) {
|
_.each(diffImages, function (imageId) {
|
||||||
var image = Images.findOne({'docker.Id': imageId});
|
var image = Images.findOne({'docker.Id': imageId});
|
||||||
if (image && image.status !== 'BUILDING') {
|
if (image && image.status === 'READY') {
|
||||||
Images.remove(image._id);
|
Images.remove(image._id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,10 +38,12 @@ Metrics.trackEvent = function (name) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var osVersion = navigator.userAgent.match(/Mac OS X (\d+_\d+_\d+)/)[1].replace(/_/g, '.');
|
||||||
mixpanel.track(name, {
|
mixpanel.track(name, {
|
||||||
distinct_id: uuid,
|
distinct_id: uuid,
|
||||||
version: app.getVersion(),
|
version: app.getVersion(),
|
||||||
product: 'Docker GUI'
|
product: 'Docker GUI',
|
||||||
|
'Operating System Version': osVersion
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<template name="dashboardAppsSettings">
|
<template name="dashboardAppsSettings">
|
||||||
|
{{#if ports}}
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="left-section">
|
<div class="left-section">
|
||||||
<h4>Ports</h4>
|
<h4>Ports</h4>
|
||||||
|
@ -9,6 +10,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{/if}}
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="left-section">
|
<div class="left-section">
|
||||||
<h4>Environment Variables</h4>
|
<h4>Environment Variables</h4>
|
||||||
|
|
|
@ -40,9 +40,7 @@ Template.modalCreateApp.events({
|
||||||
var image = Images.findOne(app.imageId);
|
var image = Images.findOne(app.imageId);
|
||||||
Util.copyVolumes(image.path, app.name, function (err) {
|
Util.copyVolumes(image.path, app.name, function (err) {
|
||||||
if (err) { console.error(err); }
|
if (err) { console.error(err); }
|
||||||
AppUtil.run(app, function (err) {
|
AppUtil.run(app, function (err) {});
|
||||||
if (err) { console.error(err); }
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
$('#modal-create-app').bind('hidden.bs.modal', function () {
|
$('#modal-create-app').bind('hidden.bs.modal', function () {
|
||||||
$('#slug-create-app-name').html('');
|
$('#slug-create-app-name').html('');
|
||||||
|
|
|
@ -32,7 +32,7 @@ Apps.helpers({
|
||||||
},
|
},
|
||||||
ports: function () {
|
ports: function () {
|
||||||
var app = this;
|
var app = this;
|
||||||
if (!app.docker || !app.docker.NetworkSettings.Ports) {
|
if (!app.docker || !app.docker.NetworkSettings || !app.docker.NetworkSettings || !app.docker.NetworkSettings.Ports) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ cd resources
|
||||||
|
|
||||||
if [ ! -f $BOOT2DOCKER_CLI_VERSION_FILE ]; then
|
if [ ! -f $BOOT2DOCKER_CLI_VERSION_FILE ]; then
|
||||||
cecho "-----> Downloading Boot2docker CLI..." $purple
|
cecho "-----> Downloading Boot2docker CLI..." $purple
|
||||||
|
rm -rf boot2docker-*
|
||||||
curl -L -o $BOOT2DOCKER_CLI_VERSION_FILE https://github.com/boot2docker/boot2docker-cli/releases/download/v${BOOT2DOCKER_CLI_VERSION}/boot2docker-v${BOOT2DOCKER_CLI_VERSION}-darwin-amd64
|
curl -L -o $BOOT2DOCKER_CLI_VERSION_FILE https://github.com/boot2docker/boot2docker-cli/releases/download/v${BOOT2DOCKER_CLI_VERSION}/boot2docker-v${BOOT2DOCKER_CLI_VERSION}-darwin-amd64
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue