diff --git a/app/docker/components/imageRegistry/por-image-registry.js b/app/docker/components/imageRegistry/por-image-registry.js
index 4c2f7b4bd..3377a2bc9 100644
--- a/app/docker/components/imageRegistry/por-image-registry.js
+++ b/app/docker/components/imageRegistry/por-image-registry.js
@@ -7,6 +7,7 @@ angular.module('portainer.docker').component('porImageRegistry', {
autoComplete: '<',
labelClass: '@',
inputClass: '@',
+ onImageChange: '&',
},
require: {
form: '^form',
diff --git a/app/docker/components/imageRegistry/porImageRegistry.html b/app/docker/components/imageRegistry/porImageRegistry.html
index feee8ba1b..27026a590 100644
--- a/app/docker/components/imageRegistry/porImageRegistry.html
+++ b/app/docker/components/imageRegistry/porImageRegistry.html
@@ -25,6 +25,7 @@
ng-model="$ctrl.model.Image"
name="image_name"
placeholder="e.g. myImage:myTag"
+ ng-change="$ctrl.onImageChange()"
required
/>
diff --git a/app/docker/views/containers/create/createContainerController.js b/app/docker/views/containers/create/createContainerController.js
index 3cb2a6a42..501a7de24 100644
--- a/app/docker/views/containers/create/createContainerController.js
+++ b/app/docker/views/containers/create/createContainerController.js
@@ -77,6 +77,8 @@ angular.module('portainer.docker').controller('CreateContainerController', [
CpuLimit: 0,
MemoryLimit: 0,
MemoryReservation: 0,
+ CmdMode: 'default',
+ EntrypointMode: 'default',
NodeName: null,
capabilities: [],
LogDriverName: '',
@@ -89,6 +91,7 @@ angular.module('portainer.docker').controller('CreateContainerController', [
$scope.state = {
formValidationError: '',
actionInProgress: false,
+ mode: '',
};
$scope.refreshSlider = function () {
@@ -97,12 +100,18 @@ angular.module('portainer.docker').controller('CreateContainerController', [
});
};
+ $scope.onImageNameChange = function () {
+ $scope.formValues.CmdMode = 'default';
+ $scope.formValues.EntrypointMode = 'default';
+ };
+
$scope.config = {
Image: '',
Env: [],
Cmd: '',
MacAddress: '',
ExposedPorts: {},
+ Entrypoint: '',
HostConfig: {
RestartPolicy: {
Name: 'no',
@@ -212,6 +221,20 @@ angular.module('portainer.docker').controller('CreateContainerController', [
config.Tty = tty;
}
+ function prepareCmd(config) {
+ if (_.isEmpty(config.Cmd) || $scope.formValues.CmdMode == 'default') {
+ delete config.Cmd;
+ } else {
+ config.Cmd = ContainerHelper.commandStringToArray(config.Cmd);
+ }
+ }
+
+ function prepareEntrypoint(config) {
+ if ($scope.formValues.EntrypointMode == 'default' || (_.isEmpty(config.Cmd) && _.isEmpty(config.Entrypoint))) {
+ config.Entrypoint = null;
+ }
+ }
+
function prepareEnvironmentVariables(config) {
var env = [];
config.Env.forEach(function (v) {
@@ -368,7 +391,8 @@ angular.module('portainer.docker').controller('CreateContainerController', [
function prepareConfiguration() {
var config = angular.copy($scope.config);
- config.Cmd = ContainerHelper.commandStringToArray(config.Cmd);
+ prepareCmd(config);
+ prepareEntrypoint(config);
prepareNetworkConfig(config);
prepareImageConfig(config);
preparePortBindings(config);
@@ -386,8 +410,16 @@ angular.module('portainer.docker').controller('CreateContainerController', [
function loadFromContainerCmd() {
if ($scope.config.Cmd) {
$scope.config.Cmd = ContainerHelper.commandArrayToString($scope.config.Cmd);
- } else {
- $scope.config.Cmd = '';
+ $scope.formValues.CmdMode = 'override';
+ }
+ }
+
+ function loadFromContainerEntrypoint() {
+ if (_.has($scope.config, 'Entrypoint')) {
+ if ($scope.config.Entrypoint == null) {
+ $scope.config.Entrypoint = '';
+ }
+ $scope.formValues.EntrypointMode = 'override';
}
}
@@ -577,8 +609,10 @@ angular.module('portainer.docker').controller('CreateContainerController', [
$scope.formValues.AccessControlData.AccessControlEnabled = false;
}
$scope.fromContainer = fromContainer;
+ $scope.state.mode = 'duplicate';
$scope.config = ContainerHelper.configFromContainer(fromContainer.Model);
loadFromContainerCmd(d);
+ loadFromContainerEntrypoint(d);
loadFromContainerLogging(d);
loadFromContainerPortBindings(d);
loadFromContainerVolumes(d);
@@ -706,7 +740,6 @@ angular.module('portainer.docker').controller('CreateContainerController', [
function create() {
var oldContainer = null;
-
HttpRequestHelper.setPortainerAgentTargetHeader($scope.formValues.NodeName);
return findCurrentContainer().then(setOldContainer).then(confirmCreateContainer).then(startCreationProcess).catch(notifyOnError).finally(final);
diff --git a/app/docker/views/containers/create/createcontainer.html b/app/docker/views/containers/create/createcontainer.html
index 14e0a89ef..01b05e60c 100644
--- a/app/docker/views/containers/create/createcontainer.html
+++ b/app/docker/views/containers/create/createcontainer.html
@@ -3,6 +3,16 @@
+
+ The new container may fail to start if the image is changed, and settings from the previous container aren't compatible. Common causes include entrypoint, cmd or
+ other settings set by an image.
+