diff --git a/README.md b/README.md index ce20e8267..b97fd6193 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Cloudinovasi UI for Docker +This UI is dedicated to CloudInovasi internal usage. + A fork of the amazing UI for Docker by Michael Crosby and Kevan Ahlquist (https://github.com/kevana/ui-for-docker) using the rdash-angular theme (https://github.com/rdash/rdash-angular).  @@ -56,7 +58,7 @@ $ docker run -d -p 10.20.30.1:80:9000 --privileged -v /var/run/docker.sock:/var/ ### Hide containers with specific labels -You can hide specific containers in the containers view by using the `-hide-label` or `-l` options and specifying a label. +You can hide specific containers in the containers view by using the `--hide-label` or `-l` options and specifying a label. For example, take a container started with the label `owner=acme`: @@ -70,6 +72,16 @@ You can hide it in the view by starting the ui with: $ docker run -d -p 9000:9000 --privileged -v /var/run/docker.sock:/var/run/docker.sock cloudinovasi/cloudinovasi-ui -l owner=acme ``` +### Custom Docker registries support + +You can specify the support of others registries than DockerHub by using the `--registries` or `-r` options and specifying a registry using the format *REGISTRY_NAME=REGISTRY_ADDRESS*. + +For example, if I want the registry 'myCustomRegistry' pointing to *myregistry.domain.com:5000* available in the UI: + +``` +$ docker run -d -p 9000:9000 --privileged -v /var/run/docker.sock:/var/run/docker.sock cloudinovasi/cloudinovasi-ui -r myCustomRegistry=myregistry.domain.com:5000 +``` + ### Available options The following options are available for the `ui-for-docker` binary: @@ -79,4 +91,5 @@ The following options are available for the `ui-for-docker` binary: * `--data`, `-d`: Path to the data folder (default: *"."*) * `--assets`, `-a`: Path to the assets (default: *"."*) * `--swarm`, `-s`: Swarm cluster support (default: *false*) -* `--hide-label`, `-l`: Hide containers with a specific label in the UI +* `--hide-label`, `-l`: Hide containers with a specific label in the UI (format *LABEL_NAME=LABEL_VALUE*) +* `--registries`, `-r`: Available registries in the UI (format *REGISTRY_NAME=REGISTRY_ADDRESS*) diff --git a/app/components/createContainer/createContainerController.js b/app/components/createContainer/createContainerController.js index 4360729dc..c61fc2495 100644 --- a/app/components/createContainer/createContainerController.js +++ b/app/components/createContainer/createContainerController.js @@ -8,9 +8,12 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, e $scope.formValues = { Console: 'none', - Volumes: [] + Volumes: [], + AvailableRegistries: [], + Registry: '', }; + $scope.imageConfig = {}; $scope.config = { Env: [], HostConfig: { @@ -51,6 +54,8 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, e Config.$promise.then(function (c) { var swarm = c.swarm; + $scope.formValues.AvailableRegistries = c.registries; + Volume.query({}, function (d) { var persistedVolumes = d.Volumes.filter(function (volume) { if (volume.Driver === 'local-persist') { @@ -105,22 +110,9 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, e }); } - function createImageConfig(imageName) { - var imageNameAndTag = imageName.split(':'); - var imageConfig = { - fromImage: imageNameAndTag[0], - tag: imageNameAndTag[1] ? imageNameAndTag[1] : 'latest' - }; - return imageConfig; - } - function pullImageAndCreateContainer(config) { $('#createContainerSpinner').show(); - - var image = _.toLower(config.Image); - var imageConfig = createImageConfig(image); - - Image.create(imageConfig, function (data) { + Image.create($scope.imageConfig, function (data) { var err = data.length > 0 && data[data.length - 1].hasOwnProperty('error'); if (err) { var detail = data[data.length - 1]; @@ -135,6 +127,28 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, e }); } + function createImageConfig(imageName, registry) { + var imageNameAndTag = imageName.split(':'); + var image = imageNameAndTag[0]; + if (registry) { + image = registry + '/' + imageNameAndTag[0]; + } + var imageConfig = { + fromImage: image, + tag: imageNameAndTag[1] ? imageNameAndTag[1] : 'latest' + }; + return imageConfig; + } + + function prepareImageConfig(config) { + var image = _.toLower(config.Image); + var registry = $scope.formValues.Registry; + var imageConfig = createImageConfig(image, registry); + console.log(JSON.stringify(imageConfig, null, 4)); + config.Image = imageConfig.fromImage + ':' + imageConfig.tag; + $scope.imageConfig = imageConfig; + } + function preparePortBindings(config) { var bindings = {}; config.HostConfig.PortBindings.forEach(function (portBinding) { @@ -194,6 +208,7 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, e function prepareConfiguration() { var config = angular.copy($scope.config); + prepareImageConfig(config); preparePortBindings(config); prepareConsole(config); prepareEnvironmentVariables(config); diff --git a/app/components/createContainer/createcontainer.html b/app/components/createContainer/createcontainer.html index e82f1ea76..819812097 100644 --- a/app/components/createContainer/createcontainer.html +++ b/app/components/createContainer/createcontainer.html @@ -18,11 +18,18 @@ - +