mirror of https://github.com/portainer/portainer
				
				
				
			Add ability to launch container from image
							parent
							
								
									406f06cb3e
								
							
						
					
					
						commit
						880966f3ba
					
				| 
						 | 
				
			
			@ -269,3 +269,46 @@ function ImageController($scope, $routeParams, $location, Image) {
 | 
			
		|||
 | 
			
		||||
    $scope.getHistory();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function StartContainerController($scope, $routeParams, $location, Container) {
 | 
			
		||||
    $scope.template = 'partials/startcontainer.html';
 | 
			
		||||
    $scope.memory = 0;
 | 
			
		||||
    $scope.memorySwap = 0;
 | 
			
		||||
    $scope.env = '';
 | 
			
		||||
    $scope.dns = '';
 | 
			
		||||
    $scope.volumesFrom = '';
 | 
			
		||||
    $scope.commands = '';
 | 
			
		||||
 | 
			
		||||
    $scope.launchContainer = function() {
 | 
			
		||||
        var cmds = null;
 | 
			
		||||
        if ($scope.commands !== '') {
 | 
			
		||||
            cmds = $scope.commands.split('\n'); 
 | 
			
		||||
        }
 | 
			
		||||
        var id = $routeParams.id;
 | 
			
		||||
        var ctor = Container;
 | 
			
		||||
        var loc = $location;
 | 
			
		||||
        var s = $scope;
 | 
			
		||||
 | 
			
		||||
        Container.create({
 | 
			
		||||
                Image: id, 
 | 
			
		||||
                Memory: $scope.memory, 
 | 
			
		||||
                MemorySwap: $scope.memorySwap, 
 | 
			
		||||
                Cmd: cmds, 
 | 
			
		||||
                VolumesFrom: $scope.volumesFrom
 | 
			
		||||
            }, function(d) {
 | 
			
		||||
                console.log(d);
 | 
			
		||||
                if (d.Id) {
 | 
			
		||||
                    ctor.start({id: d.Id}, function(cd) {
 | 
			
		||||
                        console.log(cd);
 | 
			
		||||
                        loc.path('/containers/' + d.Id + '/');
 | 
			
		||||
                    }, function(e) {
 | 
			
		||||
                        console.log(e); 
 | 
			
		||||
                        s.resonse = e.data;
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
            }, function(e) {
 | 
			
		||||
                console.log(e);
 | 
			
		||||
                $scope.response = e.data; 
 | 
			
		||||
        });
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,6 +76,11 @@
 | 
			
		|||
            </fieldset>
 | 
			
		||||
        </form>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <hr />
 | 
			
		||||
 | 
			
		||||
    <div ng-include="template" ng-controller="StartContainerController"></div>
 | 
			
		||||
 | 
			
		||||
    <hr />
 | 
			
		||||
 | 
			
		||||
    <div class="btn-remove">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
 | 
			
		||||
<div>
 | 
			
		||||
    {{ response }}
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<form>
 | 
			
		||||
    <fieldset>
 | 
			
		||||
        <legend>Start container from Image</legend>
 | 
			
		||||
 | 
			
		||||
        <label>Cmd:</label>
 | 
			
		||||
        <textarea ng-model="commands" rows="6"></textarea>
 | 
			
		||||
        <small>Place each command on a new line</small>
 | 
			
		||||
 | 
			
		||||
        <label>Memory:</label>
 | 
			
		||||
        <input type="number" ng-model="memory"/>
 | 
			
		||||
 | 
			
		||||
        <label>Memory Swap:</label>
 | 
			
		||||
        <input type="number" ng-model="memorySwap"/>
 | 
			
		||||
 | 
			
		||||
        <label>Volumes From:</label>
 | 
			
		||||
        <input type="text" ng-model="volumesFrom"/>
 | 
			
		||||
 | 
			
		||||
        <br />
 | 
			
		||||
        <input type="button" ng-click="launchContainer()" value="Launch" />
 | 
			
		||||
    </fieldset>
 | 
			
		||||
</form>
 | 
			
		||||
		Loading…
	
		Reference in New Issue