diff --git a/app/constants.js b/app/constants.js
index c4f911034..9b92ddf87 100644
--- a/app/constants.js
+++ b/app/constants.js
@@ -15,4 +15,5 @@ angular.module('portainer')
.constant('API_ENDPOINT_TEMPLATES', 'api/templates')
.constant('DEFAULT_TEMPLATES_URL', 'https://raw.githubusercontent.com/portainer/templates/master/templates.json')
.constant('PAGINATION_MAX_ITEMS', 10)
-.constant('APPLICATION_CACHE_VALIDITY', 3600);
+.constant('APPLICATION_CACHE_VALIDITY', 3600)
+.constant('CONSOLE_COMMANDS_LABEL_PREFIX', 'io.portainer.commands.');
diff --git a/app/docker/views/containers/console/containerConsoleController.js b/app/docker/views/containers/console/containerConsoleController.js
index f877c5836..9f29e11dd 100644
--- a/app/docker/views/containers/console/containerConsoleController.js
+++ b/app/docker/views/containers/console/containerConsoleController.js
@@ -1,6 +1,6 @@
angular.module('portainer.docker')
-.controller('ContainerConsoleController', ['$scope', '$transition$', 'ContainerService', 'ImageService', 'EndpointProvider', 'Notifications', 'ContainerHelper', 'ExecService', 'HttpRequestHelper', 'LocalStorage',
-function ($scope, $transition$, ContainerService, ImageService, EndpointProvider, Notifications, ContainerHelper, ExecService, HttpRequestHelper, LocalStorage) {
+.controller('ContainerConsoleController', ['$scope', '$transition$', 'ContainerService', 'ImageService', 'EndpointProvider', 'Notifications', 'ContainerHelper', 'ExecService', 'HttpRequestHelper', 'LocalStorage', 'CONSOLE_COMMANDS_LABEL_PREFIX',
+function ($scope, $transition$, ContainerService, ImageService, EndpointProvider, Notifications, ContainerHelper, ExecService, HttpRequestHelper, LocalStorage, CONSOLE_COMMANDS_LABEL_PREFIX) {
var socket, term;
$scope.state = {
@@ -9,6 +9,7 @@ function ($scope, $transition$, ContainerService, ImageService, EndpointProvider
};
$scope.formValues = {};
+ $scope.containerCommands = [];
// Ensure the socket is closed before leaving the view
$scope.$on('$stateChangeStart', function (event, next, current) {
@@ -106,8 +107,16 @@ function ($scope, $transition$, ContainerService, ImageService, EndpointProvider
})
.then(function success(data) {
var image = data;
+ var containerLabels = $scope.container.Config.Labels;
$scope.imageOS = image.Os;
$scope.formValues.command = image.Os === 'windows' ? 'powershell' : 'bash';
+ $scope.containerCommands = Object.keys(containerLabels)
+ .filter(function(label) {
+ return label.indexOf(CONSOLE_COMMANDS_LABEL_PREFIX) === 0;
+ })
+ .map(function(label) {
+ return {title: label.replace(CONSOLE_COMMANDS_LABEL_PREFIX, ''), command: containerLabels[label]};
+ });
$scope.state.loaded = true;
})
.catch(function error(err) {
diff --git a/app/docker/views/containers/console/containerconsole.html b/app/docker/views/containers/console/containerconsole.html
index f8b4e7e54..e938c49c0 100644
--- a/app/docker/views/containers/console/containerconsole.html
+++ b/app/docker/views/containers/console/containerconsole.html
@@ -27,6 +27,7 @@
+