Merge pull request #1691 from sibprogrammer/privileged-containers

Add ability to run privileged containers (fix #269).
This commit is contained in:
French Ben 2016-05-23 17:15:26 -07:00
Родитель c05fe9b5fa ab1c7fa66f
Коммит 2650894bf0
2 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -1,3 +1,4 @@
import _ from 'underscore';
import React from 'react/addons';
import metrics from '../utils/MetricsUtil';
import ContainerUtil from '../utils/ContainerUtil';
@ -11,10 +12,11 @@ var ContainerSettingsAdvanced = React.createClass({
},
getInitialState: function () {
let [tty, openStdin] = ContainerUtil.mode(this.props.container) || [true, true];
let [tty, openStdin, privileged] = ContainerUtil.mode(this.props.container) || [true, true, false];
return {
tty: tty,
openStdin: openStdin
openStdin: openStdin,
privileged: privileged
};
},
@ -22,7 +24,9 @@ var ContainerSettingsAdvanced = React.createClass({
metrics.track('Saved Advanced Options');
let tty = this.state.tty;
let openStdin = this.state.openStdin;
containerActions.update(this.props.container.Name, {Tty: tty, OpenStdin: openStdin});
let privileged = this.state.privileged;
let hostConfig = _.extend(this.props.container.HostConfig, {Privileged: privileged});
containerActions.update(this.props.container.Name, {Tty: tty, OpenStdin: openStdin, HostConfig: hostConfig});
},
handleChangeTty: function () {
@ -37,6 +41,12 @@ var ContainerSettingsAdvanced = React.createClass({
});
},
handleChangePrivileged: function () {
this.setState({
privileged: !this.state.privileged
});
},
render: function () {
if (!this.props.container) {
return false;
@ -49,6 +59,7 @@ var ContainerSettingsAdvanced = React.createClass({
<div className="checkboxes">
<p><input type="checkbox" checked={this.state.tty} onChange={this.handleChangeTty}/>Allocate a TTY for this container</p>
<p><input type="checkbox" checked={this.state.openStdin} onChange={this.handleChangeOpenStdin}/>Keep STDIN open even if not attached</p>
<p><input type="checkbox" checked={this.state.privileged} onChange={this.handleChangePrivileged}/>Privileged mode</p>
</div>
<a className="btn btn-action" disabled={this.props.container.State.Updating} onClick={this.handleSaveAdvancedOptions}>Save</a>
</div>

Просмотреть файл

@ -15,10 +15,11 @@ var ContainerUtil = {
// Provide Foreground options
mode: function (container) {
if (!container || !container.Config) {
return [true, true];
}
return [container.Config.Tty, container.Config.OpenStdin];
return [
(container && container.Config) ? container.Config.Tty : true,
(container && container.Config) ? container.Config.OpenStdin : true,
(container && container.HostConfig) ? container.HostConfig.Privileged : false
];
},
// TODO: inject host here instead of requiring Docker