mirror of https://github.com/portainer/portainer
feat(area-endpoints/creation): allow custom Docker socket (#4772) and handle public IP, group and tags for docket sockets (#4798)
* fix(endpoints/creation): hide TLS, make use of PublicIP, Groups, Tags for local Docker endpoint * feat(endpoints/creation): allow specifying custom Docker socket (#4772) * feat(endpoints/creation): override default socket path * fix(endpoints/creation): typo socketPath -> SocketPathpull/4909/head
parent
52d4296c08
commit
3dccc59048
|
@ -58,10 +58,20 @@ angular.module('portainer.app').factory('EndpointService', [
|
|||
return Endpoints.remove({ id: endpointID }).$promise;
|
||||
};
|
||||
|
||||
service.createLocalEndpoint = function (name = 'local') {
|
||||
service.createLocalEndpoint = function (name = 'local', URL = '', PublicURL = '', groupID = 1, tagIds = []) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
FileUploadService.createEndpoint(name, PortainerEndpointCreationTypes.LocalDockerEnvironment, '', '', 1, [], false)
|
||||
var endpointURL = URL;
|
||||
if (endpointURL !== '') {
|
||||
if (endpointURL.indexOf('//./pipe/') == 0) {
|
||||
// Windows named pipe
|
||||
endpointURL = 'npipe://' + URL;
|
||||
} else {
|
||||
endpointURL = 'unix://' + URL;
|
||||
}
|
||||
}
|
||||
|
||||
FileUploadService.createEndpoint(name, PortainerEndpointCreationTypes.LocalDockerEnvironment, endpointURL, PublicURL, groupID, tagIds, false)
|
||||
.then(function success(response) {
|
||||
deferred.resolve(response.data);
|
||||
})
|
||||
|
|
|
@ -100,12 +100,18 @@ angular
|
|||
}
|
||||
|
||||
$scope.addDockerEndpoint = function () {
|
||||
var name = $scope.formValues.Name;
|
||||
var URL = $filter('stripprotocol')($scope.formValues.URL);
|
||||
var publicURL = $scope.formValues.PublicURL;
|
||||
var groupId = $scope.formValues.GroupId;
|
||||
var tagIds = $scope.formValues.TagIds;
|
||||
|
||||
if ($scope.formValues.ConnectSocket) {
|
||||
var endpointName = $scope.formValues.Name;
|
||||
URL = $scope.formValues.SocketPath;
|
||||
$scope.state.actionInProgress = true;
|
||||
EndpointService.createLocalEndpoint(endpointName)
|
||||
EndpointService.createLocalEndpoint(name, URL, publicURL, groupId, tagIds)
|
||||
.then(function success() {
|
||||
Notifications.success('Endpoint created', endpointName);
|
||||
Notifications.success('Endpoint created', name);
|
||||
$state.go('portainer.endpoints', {}, { reload: true });
|
||||
})
|
||||
.catch(function error(err) {
|
||||
|
@ -115,11 +121,9 @@ angular
|
|||
$scope.state.actionInProgress = false;
|
||||
});
|
||||
} else {
|
||||
var name = $scope.formValues.Name;
|
||||
var URL = $filter('stripprotocol')($scope.formValues.URL);
|
||||
var publicURL = $scope.formValues.PublicURL === '' ? URL.split(':')[0] : $scope.formValues.PublicURL;
|
||||
var groupId = $scope.formValues.GroupId;
|
||||
var tagIds = $scope.formValues.TagIds;
|
||||
if (publicURL === '') {
|
||||
publicURL = URL.split(':')[0];
|
||||
}
|
||||
|
||||
var securityData = $scope.formValues.SecurityFormData;
|
||||
var TLS = securityData.TLS;
|
||||
|
|
|
@ -210,6 +210,42 @@
|
|||
<label class="switch" style="margin-left: 20px;"> <input type="checkbox" ng-model="formValues.ConnectSocket" /><i></i> </label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="state.EnvironmentType === 'docker' && formValues.ConnectSocket">
|
||||
<div class="form-group" style="padding-left: 15px;">
|
||||
<label for="override_socket" class="col-sm_12 control-label text-left">
|
||||
Override default socket path
|
||||
</label>
|
||||
<label class="switch" style="margin-left: 20px;"> <input type="checkbox" ng-model="formValues.OverrideSocket" /><i></i> </label>
|
||||
</div>
|
||||
|
||||
<div ng-if="formValues.OverrideSocket">
|
||||
<div class="form-group">
|
||||
<label for="socket_path" class="col-sm-3 col-lg-2 control-label text-left">
|
||||
Socket path
|
||||
<portainer-tooltip position="bottom" message="Path to the Docker socket. Remember to bind-mount the socket, see the important notice above for more information.">
|
||||
</portainer-tooltip>
|
||||
</label>
|
||||
<div class="col-sm-9 col-lg-10">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
name="socket_path"
|
||||
ng-model="formValues.SocketPath"
|
||||
placeholder="e.g. /var/run/docker.sock (on Linux) or //./pipe/docker_engine (on Windows)"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" ng-show="endpointCreationForm.socket_path.$invalid">
|
||||
<div class="col-sm-12 small text-warning">
|
||||
<div ng-messages="endpointCreationForm.socket_path.$error">
|
||||
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- !connect-via-socket-input -->
|
||||
<!-- endpoint-url-input -->
|
||||
<div ng-if="(state.EnvironmentType === 'docker' && !formValues.ConnectSocket) || state.EnvironmentType === 'agent'">
|
||||
|
@ -378,7 +414,7 @@
|
|||
</div>
|
||||
<!-- !azure-details -->
|
||||
<!-- endpoint-security -->
|
||||
<por-endpoint-security ng-if="state.EnvironmentType === 'docker'" form-data="formValues.SecurityFormData"></por-endpoint-security>
|
||||
<por-endpoint-security ng-if="state.EnvironmentType === 'docker' && !formValues.ConnectSocket" form-data="formValues.SecurityFormData"></por-endpoint-security>
|
||||
<!-- !endpoint-security -->
|
||||
<div class="col-sm-12 form-section-title">
|
||||
Metadata
|
||||
|
|
|
@ -173,7 +173,7 @@ function shell_run_container() {
|
|||
'docker rm -f portainer',
|
||||
'docker run -d -p 8000:8000 -p 9000:9000 -v $(pwd)/dist:/app -v ' +
|
||||
portainer_data +
|
||||
':/data -v /var/run/docker.sock:/var/run/docker.sock:z -v /tmp:/tmp --name portainer portainer/base /app/portainer',
|
||||
':/data -v /var/run/docker.sock:/var/run/docker.sock:z -v /var/run/docker.sock:/var/run/alternative.sock:z -v /tmp:/tmp --name portainer portainer/base /app/portainer',
|
||||
].join(';');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue