From e7e5957a1b12ceac855e1ae570ba6b1f76090152 Mon Sep 17 00:00:00 2001 From: TeckniX Date: Wed, 17 Jun 2015 14:38:09 -0400 Subject: [PATCH 1/2] Added support for docker tty stdin options Signed-off-by: TeckniX --- .../ContainerSettingsGeneral.react.js | 29 +++++++++++++++++-- src/utils/ContainerUtil.js | 8 +++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/components/ContainerSettingsGeneral.react.js b/src/components/ContainerSettingsGeneral.react.js index e95bee4b06..cc05d1efcc 100644 --- a/src/components/ContainerSettingsGeneral.react.js +++ b/src/components/ContainerSettingsGeneral.react.js @@ -22,10 +22,14 @@ var ContainerSettingsGeneral = React.createClass({ return [util.randomId(), e[0], e[1]]; }); + let [tty, openStdin] = ContainerUtil.mode(this.props.container) || [false, false]; + return { slugName: null, nameError: null, - env: env + env: env, + tty: tty, + openStdin: openStdin }; }, @@ -90,7 +94,9 @@ var ContainerSettingsGeneral = React.createClass({ list.push(key + '=' + value); } }); - containerActions.update(this.props.container.Name, {Env: list}); + let tty = this.state.tty; + let openStdin = this.state.openStdin; + containerActions.update(this.props.container.Name, {Env: list, Tty: tty, OpenStdin: openStdin}); }, handleChangeEnvKey: function (index, event) { @@ -133,6 +139,18 @@ var ContainerSettingsGeneral = React.createClass({ metrics.track('Removed Environment Variable'); }, + handleChangeTty: function () { + this.setState({ + tty: !this.state.tty + }); + }, + + handleChangeOpenStdin: function () { + this.setState({ + openStdin: !this.state.openStdin + }); + }, + handleDeleteContainer: function () { dialog.showMessageBox({ message: 'Are you sure you want to delete this container?', @@ -211,6 +229,13 @@ var ContainerSettingsGeneral = React.createClass({
{vars}
+ +
+
+

Foreground Options

+

Attach standard streams to a tty, including stdin if it is not closed

+

Keep STDIN open even if not attached

+
Save
diff --git a/src/utils/ContainerUtil.js b/src/utils/ContainerUtil.js index 4d6016ce6e..d4afb983cd 100644 --- a/src/utils/ContainerUtil.js +++ b/src/utils/ContainerUtil.js @@ -13,6 +13,14 @@ var ContainerUtil = { }); }, + // Provide Foreground options + mode: function (container) { + if (!container || !container.Config) { + return [false, false]; + } + return [container.Config.Tty, container.Config.OpenStdin]; + }, + // TODO: inject host here instead of requiring Docker ports: function (container) { if (!container || !container.NetworkSettings) { From ef1c69f56c9cc371b2a4bc02db1870acf8a61542 Mon Sep 17 00:00:00 2001 From: TeckniX Date: Thu, 18 Jun 2015 12:10:29 -0400 Subject: [PATCH 2/2] Updated option text and added default of on for tty and stdin during initial container creation --- src/components/ContainerSettingsGeneral.react.js | 4 ++-- src/utils/ContainerUtil.js | 2 +- src/utils/DockerUtil.js | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/ContainerSettingsGeneral.react.js b/src/components/ContainerSettingsGeneral.react.js index cc05d1efcc..af6cf08285 100644 --- a/src/components/ContainerSettingsGeneral.react.js +++ b/src/components/ContainerSettingsGeneral.react.js @@ -22,7 +22,7 @@ var ContainerSettingsGeneral = React.createClass({ return [util.randomId(), e[0], e[1]]; }); - let [tty, openStdin] = ContainerUtil.mode(this.props.container) || [false, false]; + let [tty, openStdin] = ContainerUtil.mode(this.props.container) || [true, true]; return { slugName: null, @@ -232,7 +232,7 @@ var ContainerSettingsGeneral = React.createClass({
-

Foreground Options

+

Advanced Options

Attach standard streams to a tty, including stdin if it is not closed

Keep STDIN open even if not attached

diff --git a/src/utils/ContainerUtil.js b/src/utils/ContainerUtil.js index d4afb983cd..b94c1632c5 100644 --- a/src/utils/ContainerUtil.js +++ b/src/utils/ContainerUtil.js @@ -16,7 +16,7 @@ var ContainerUtil = { // Provide Foreground options mode: function (container) { if (!container || !container.Config) { - return [false, false]; + return [true, true]; } return [container.Config.Tty, container.Config.OpenStdin]; }, diff --git a/src/utils/DockerUtil.js b/src/utils/DockerUtil.js index 46dceeb5a1..d1e38fedac 100644 --- a/src/utils/DockerUtil.js +++ b/src/utils/DockerUtil.js @@ -25,8 +25,6 @@ export default { throw new Error('Certificate directory does not exist'); } - console.log(ip); - this.host = ip; this.client = new dockerode({ protocol: 'https', @@ -103,6 +101,7 @@ export default { containerData.Env = containerData.Config.Env; } + containerData.Volumes = _.mapObject(containerData.Volumes, () => {return {};}); let existing = this.client.getContainer(name); @@ -162,6 +161,8 @@ export default { Config: { Image: imageName, }, + Tty: true, + OpenStdin: true, State: { Downloading: true } @@ -183,7 +184,7 @@ export default { delete this.placeholders[name]; localStorage.setItem('placeholders', JSON.stringify(this.placeholders)); - this.createContainer(name, {Image: imageName}); + this.createContainer(name, {Image: imageName, Tty: true, OpenStdin: true}); }, // progress is actually the progression PER LAYER (combined in columns)